home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / assembler-tools / apathysource / loader / introloader.s < prev    next >
Encoding:
Text File  |  1980-02-04  |  75.1 KB  |  3,538 lines

  1.  
  2.            machine   68020               ;Will only run with 68020+.
  3.  
  4.  
  5. ;;; "The Player Defines                             ;Type of player,"
  6. opt020 = 1         ;0 = The Player will use MC680x0 code
  7.            ;1 = MC68020+ or better
  8.  
  9. start = 0       ;Starting position
  10.  
  11. fade  = 1       ;0 = Normal, NO master volume control possible
  12.         ;1 = Use master volume (P61_Master)
  13.  
  14. jump = 1        ;0 = do NOT include position jump code (P61_SetPosition)
  15.         ;1 = Include
  16.  
  17. system = 0      ;0 = killer
  18.         ;1 = friendly
  19.  
  20. CIA = 1         ;0 = CIA disabled
  21.         ;1 = CIA enabled
  22.  
  23. exec = 1        ;0 = ExecBase destroyed
  24.         ;1 = ExecBase valid
  25.  
  26. lev6 = 1        ;0 = NonLev6
  27.         ;1 = Lev6 used
  28.  
  29. channels = 4    ;amount of channels to be played
  30.  
  31. use = $4040945D   ;The Usecode
  32. ;;;
  33.                          ;startposition, usecode,
  34.                          ;020 etc.
  35. ;;; "Includes                                       ;Needed to make things"
  36.  
  37.            Incdir    "!Includes:"
  38.            Include   "StdLibInc.i"       ;LVOs, ExecBase define.
  39.            Include   "StdHardInc.i"      ;Registers, Custom define.
  40.  
  41.            Incdir    "!Includes:OS3.0/"
  42.            Include   "exec/memory.i"
  43.            Include   "exec/ExecBase.i"
  44.            Include   "graphics/GfxBase.i"
  45.            Include   "dos/dosextens.i"
  46.            Include   "devices/input.i"
  47.            Include   "devices/inputevent.i"
  48.            Include   "intuition/screens.i"
  49.            Include   "graphics/videocontrol.i"
  50.  
  51.            Incdir    "work:coding/player6.1A/source/Include/"
  52.            Include   "Player61.i"
  53. ;;;
  54.                          ;more readable!
  55. ;;; "Exported variables                             ;Variables you use"
  56.            IFD       noexample
  57.            xdef      _Startup
  58.            xdef      _Closedown
  59.            xdef      _InitDemo
  60.            xdef      _UninitDemo
  61.            xdef      _PlayMusic
  62.            xdef      _StopMusic
  63.  
  64.            xdef      _GfxBase
  65.            xdef      _DosBase
  66.            xdef      _IntBase
  67.            xdef      SpriteDummy
  68.  
  69.            xdef      P61_Master
  70.            xdef      P61_Play
  71.            xdef      P61_Pos
  72.            xdef      P61_Patt
  73.            xdef      P61_CRow
  74.            xdef      P61_E8
  75.            xdef      P61_VBR
  76.  
  77.            xdef      _FastMem
  78.            xdef      _CPU
  79.            xdef      _VBR
  80.  
  81.            ;SYSOP VARS! - DON'T USE!
  82.            ;------------------------
  83.  
  84.            xdef      OldInt
  85.            xdef      OldDMA
  86.            xdef      OldLev3
  87.  
  88.            xdef      SyncBit
  89.  
  90.            ENDC
  91. ;;;
  92.                          ;in your program when
  93.                          ;linked with this program.
  94.                          ;I.e. To get _GfxBase,
  95.                          ;synchronizing with music,
  96.                          ;init demo, fade colours,
  97.                          ;set pointers, play music.
  98. ;;; "Loader Defines"
  99. HANDLER_PRI        Equ       127
  100. ;;;
  101.  
  102.            xref      _Sync
  103.  
  104.            Section   code,CODE
  105.  
  106.            IFND      noexample
  107. StartOfProgg:
  108. ;;; "                 Init"
  109.            Bsr       _Startup            ;Iconstartup
  110.  
  111.            Bsr       _InitDemo
  112.            Tst.l     d0
  113.            Bne       Exit
  114. ;;;
  115. ;;; "                 Play Music"
  116.            Bsr       _PlayMusic
  117.            Tst.l     d0
  118.            Bne       CloseDown
  119. ;;;
  120.  
  121. Loop:              Move.w    #$0000,$dff180
  122.            Move.w    #$0f00,$dff180
  123.            Btst      #6,$bfe001
  124.            Bne       Loop
  125.  
  126. ;;; "                 Stop Music"
  127.            Bsr       _StopMusic
  128. ;;;
  129. ;;; "                 Uninit"
  130. CloseDown:         Bsr       _UninitDemo
  131.            Bsr       _Closedown          ;Iconstartup
  132. ;;;
  133.  
  134. Exit:              Moveq     #0,d0
  135.            Rts
  136.            ENDC
  137.  
  138.            IFD       kulig
  139. ;;; "Install Input Handler"
  140.         ; Create main program port
  141. InstallIH:
  142.         Move.l  (_ExecBase).w,a6
  143.         Moveq.l #0,d0                   ; Get port pri
  144.         Lea     nameString(pc),a0       ; Get port name
  145.         bsr     init_crport             ; Create new port
  146.         tst.l   d0                      ; Succeeded?
  147.         beq     ina_err                 ; Skip if not
  148.         Lea     base(pc),a4
  149.         Move.l  d0,mainPort-base(a4)    ; Store port address in memory
  150.  
  151.         ; Create io request
  152.         Move.l  mainPort-base(a4),a0    ; Get port ptr
  153.         move.l  #IOSTD_SIZE,d0          ; Get request size
  154.         bsr     init_crextio            ; Create extio
  155.         tst.l   d0                      ; Succeeded?
  156.         beq     ina_err                 ; Skip if not
  157.         Lea     base(pc),a4
  158.         Move.l  d0,extIO-base(a4)       ; Store ptr in memory
  159.  
  160.         ; Open input.device
  161.         Move.l  (_ExecBase).w,a6        ; Get system base
  162.         Lea     inputName-base(a4),a0   ; Get device name
  163.         move.l  d0,a1                   ; Get extio address
  164.         moveq.l #0,d0                   ; Unit number 0
  165.         move.l  d0,d1                   ; No special flags
  166.         Jsr     _LVOOpenDevice(a6)      ; Open device
  167.         tst.l   d0                      ; Succeeded?
  168.         bne     ina_err                 ; Skip if not
  169.         Move.w  #-1,inputOpen-base(a4)  ; Set input.device open flag
  170.  
  171.         ; Install input handler
  172.         Lea     inputHandler(pc),a0     ; Get input handler info addr
  173.         Lea     ihandler(pc),a2
  174.         Move.l  a2,IS_CODE(a0)          ; Store ptr to routine
  175.         move.l  #0,IS_DATA(a0)          ; No special data ptr
  176.         move.b  #HANDLER_PRI,LN_PRI(a0) ; High priority handler
  177.         Lea     nameString(pc),a2
  178.         Move.l  a2,LN_NAME(a0)          ; Store name of program
  179.         Move.l  extIO-base(a4),a1       ; Get addr of io request
  180.         move.l  a0,IO_DATA(a1)          ; Store handler ptr
  181.         move.w  #IND_ADDHANDLER,IO_COMMAND(a1)  ; Command: add input handler
  182.         Jsr     _LVODoIO(a6)            ; Add handler
  183.         Move.w  #-1,handlerInst-base(a4)        ; Set handler installed flag
  184.  
  185.         Moveq   #0,d0
  186.         Rts
  187.  
  188. ina_err:        Bsr     RemoveIH
  189.  
  190.         Moveq   #1,d0
  191.         Rts
  192. ;;;
  193. ;;; "Remove Input Handler"
  194. RemoveIH:       Move.l  (_ExecBase).w,a6
  195.         Lea     base(pc),a4
  196. rsa_noint:      Tst.w   handlerInst-base(a4)    ; Handler installed?
  197.         beq     rsa_nohandler           ; Skip if not
  198.         Move.l  extIO-base(a4),a1       ; Get address of io request
  199.         Lea     inputHandler(pc),a2
  200.         Move.l  a2,IO_DATA(a1)          ; Get address of handler info
  201.         move.w  #IND_REMHANDLER,IO_COMMAND(a1)  ; Command for removing handler
  202.         Jsr     _LVODoIO(a6)            ; Remove handler
  203.         
  204. rsa_nohandler:  Tst.w   inputOpen-base(a4)      ; Input device opened?
  205.         beq     rsa_noinput             ; Skip if not
  206.         Move.l  extIO-base(a4),a1       ; Get io request for input.device
  207.         Jsr     _LVOCloseDevice(a6)     ; Close device
  208.  
  209. rsa_noinput:    Tst.l   extIO-base(a4)          ; Extended io request allocated?
  210.         beq     cla_noreq               ; Skip if not
  211.         Move.l  extIO-base(a4),a0       ; Get extio pointer
  212.         move.l  #IOSTD_SIZE,d0          ; Get req size
  213.         bsr     init_delextio           ; Free struct
  214.  
  215. cla_noreq:
  216.         Lea     base(pc),a4
  217.         Tst.l   mainPort-base(a4)       ; Port created?
  218.         beq     cla_noport              ; Skip if not
  219.         Move.l  mainPort-base(a4),a0    ; Get port address
  220.         bsr     init_delport            ; Remove it
  221.  
  222. cla_noport:     Rts
  223. ;;;
  224. ;;; "  init_crport"
  225. ; Create message port and add to system
  226. ; d0: Priority
  227. ; a0: Ptr to name string
  228. ; Returns: Ptr to port or zero if failure
  229. init_crport:    movem.l d2-d3,-(a7)
  230.         move.l  (_ExecBase).w,a6
  231.  
  232.         ; Allocate port signal
  233.         movem.l d0/a0,-(a7)
  234.         moveq.l #-1,d0                  ; Allocate whatever signal
  235.         Jsr     _LVOAllocSignal(a6)     ; Call routine
  236.         move.l  d0,d2
  237.         movem.l (a7)+,d0/a0
  238.         cmp.w   #-1,d2                  ; Allocation successful?
  239.         beq     crp_error0              ; Skip if not
  240.  
  241.         ; Allocate port memory
  242.         movem.l d0/a0,-(a7)
  243.         moveq.l #MP_SIZE,d0
  244.         move.l  #MEMF_CLEAR!MEMF_PUBLIC,d1      ; Clear memory
  245.         Jsr     _LVOAllocMem(a6)        ; Allocate
  246.         move.l  d0,d3
  247.         movem.l (a7)+,d0/a0
  248.         tst.l   d3                      ; Allocation successful?
  249.         beq     crp_error1              ; Skip if not
  250.         move.l  d3,a1
  251.  
  252.         ; Initialize port members
  253.         move.l  a0,LN_NAME(a1)
  254.         move.b  d0,LN_PRI(a1)
  255.         move.b  #NT_MSGPORT,LN_TYPE(a1)
  256.         move.b  #PA_SIGNAL,MP_FLAGS(a1)
  257.         move.b  d2,MP_SIGBIT(a1)
  258.         move.l  a1,-(a7)
  259.         moveq.l #0,d0
  260.         move.l  d0,a1                   ; Zero ptr for own task struct
  261.         Jsr     _LVOFindTask(a6)        ; Get address of current task
  262.         move.l  (a7)+,a1
  263.         move.l  d0,MP_SIGTASK(a1)       ; Store in port
  264.  
  265.         ; Add port to system list
  266.         move.l  a1,-(a7)
  267.         Jsr     _LVOAddPort(a6)
  268.         move.l  (a7)+,a1
  269.         move.l  a1,d0                   ; Get port address
  270.         movem.l (a7)+,d2-d3
  271.         rts
  272.  
  273. crp_error1:     move.l  d2,d0
  274.         Jsr     _LVOFreeSignal(a6)      ; Free allocated signal
  275. crp_error0:     moveq.l #0,d0                   ; Return error
  276.         movem.l (a7)+,d2-d3
  277.         rts
  278. ;;;
  279. ;;; "  init_delport"
  280. ; Delete message port
  281. ; a0: Ptr to message port
  282. init_delport:   move.l  d2,-(a7)
  283.         move.l  (_ExecBase).w,a6
  284.  
  285.         ; Remove port from system list
  286.         move.l  a0,d2                   ; d2 used as temporary storage
  287.         move.l  a0,a1
  288.         Jsr     _LVORemPort(a6)
  289.  
  290.         ; Free port signal
  291.         move.l  d2,a0
  292.         moveq.l #0,d0
  293.         move.b  MP_SIGBIT(a0),d0
  294.         Jsr     _LVOFreeSignal(a6)
  295.  
  296.         ; Free port memory
  297.         move.l  d2,a1
  298.         moveq.l #MP_SIZE,d0
  299.         Jsr     _LVOFreeMem(a6)
  300.         move.l  (a7)+,d2
  301.         rts
  302. ;;;
  303. ;;; "  init_crextio"
  304. ; Create extended io request
  305. ; a0: Ptr to reply port for this request
  306. ; d0: Size of request struct
  307. ; Returns: Ptr to extio struct or zero if failure
  308. init_crextio:   move.l  a2,-(a7)
  309.         move.l  a0,d1                   ; Port present?
  310.         beq     cre_error0              ; Skip if not
  311.         move.l  a0,a2                   ; Store port ptr for later use
  312.         move.l  (_ExecBase).w,a6
  313.         move.l  #MEMF_CLEAR!MEMF_PUBLIC,d1      ; Clear memory
  314.         Jsr     _LVOAllocMem(a6)        ; Allocate extio memory
  315.         tst.l   d0                      ; Succeeded?
  316.         beq     cre_error0              ; Skip if not
  317.         move.l  d0,a0
  318.         move.b  #NT_MESSAGE,LN_TYPE(a0) ; Set node type to message
  319.         move.l  a2,MN_REPLYPORT(a0)     ; Set reply port address
  320.         bra     cre_exit
  321.  
  322. cre_error0:     moveq.l #0,d0                   ; Return failure
  323. cre_exit:       move.l  (a7)+,a2
  324.         rts
  325. ;;;
  326. ;;; "  init_delextio"
  327. ; Delete extended io request
  328. ; a0: Ptr to io request
  329. ; d0: Size of request struct
  330. init_delextio:  move.b  #$ff,LN_TYPE(a0)        ; Invalid type number
  331.         move.l  #-1,IO_DEVICE(a0)       ; Invalid device ptr
  332.         move.l  #-1,IO_UNIT(a0)         ; Invalid unit ptr
  333.         move.l  (_ExecBase).w,a6
  334.         move.l  a0,a1                   ; Get extio addr
  335.         Jsr     _LVOFreeMem(a6)         ; Free memory
  336.         rts
  337. ;;;
  338. ;;; "  ihandler"
  339. ; Delink keyboard and mouse events so Intuition won't hear of them
  340. ihandler:       movem.l a0-a2,-(a7)
  341. ih_headloop:    move.b  ie_Class(a0),d0         ; Get event class
  342.         cmp.b   #IECLASS_RAWKEY,d0      ; Is it keypress?
  343.         beq     ih_hrawkey              ; Delink if true
  344.         cmp.b   #IECLASS_RAWMOUSE,d0    ; Is it mouse event?
  345.         beq     ih_hrawmouse            ; Handle if true
  346.         cmp.b   #IECLASS_POINTERPOS,d0  ; Is it mouse event?
  347.         beq     ih_hdlink               ; Delink if true
  348.         cmp.b   #IECLASS_NEWPOINTERPOS,d0       ; Is it mouse event?
  349.         beq     ih_hdlink               ; Delink if true
  350.         bra     ih_nothead              ; Skip to tail processing part
  351. ih_hdlink:      move.l  ie_NextEvent(a0),d0     ; Get address of next event
  352.         move.l  d0,a0                   ; Any more events left?
  353.         bne     ih_headloop             ; Loop if true
  354.         moveq.l #0,d0                   ; All events removed
  355.         movem.l (a7)+,a0-a2
  356.         rts                             ; End routine
  357.  
  358.         ; Handle rawkey events at the head of the chain
  359. ih_hrawkey:     move.l  a0,a2                   ; Move to correct register
  360.         bsr     ih_dorawkey             ; Handle event
  361.         bra     ih_hdlink               ; Delink event
  362.  
  363.         ; Handle rawmouse events at the head of the chain
  364. ih_hrawmouse:   move.l  a0,a2                   ; Move to correct register
  365.         bsr     ih_dorawmouse           ; Handle event
  366.         bra     ih_hdlink               ; Delink event
  367.  
  368. ih_nothead:     move.l  a0,a1                   ; Store ptr to previous event
  369.         move.l  a0,a2                   ; Store ptr to current event
  370. ih_midloop:     move.l  ie_NextEvent(a2),d0     ; Get address of next event
  371.         move.l  d0,a2                   ; More events to process?
  372.         beq     ih_end                  ; Skip if not
  373.         move.b  ie_Class(a2),d0         ; Get event class
  374.         cmp.b   #IECLASS_RAWKEY,d0      ; Is it keypress?
  375.         beq     ih_mrawkey              ; Delink if true
  376.         cmp.b   #IECLASS_RAWMOUSE,d0    ; Is it mouse event?
  377.         beq     ih_mrawmouse            ; Delink if true
  378.         cmp.b   #IECLASS_POINTERPOS,d0  ; Is it mouse event?
  379.         beq     ih_mdlink               ; Delink if true
  380.         cmp.b   #IECLASS_NEWPOINTERPOS,d0       ; Is it mouse event?
  381.         beq     ih_mdlink               ; Delink if true
  382.         move.l  a2,a1                   ; Store current as previous
  383.         bra     ih_midloop
  384. ih_mdlink:      move.l  ie_NextEvent(a2),ie_NextEvent(a1)       ; Delink event
  385.         bra     ih_midloop
  386.  
  387. ih_end:         move.l  a0,d0                   ; Store start of chain in return reg
  388.         movem.l (a7)+,a0-a2
  389.         rts                             ; End routine
  390.  
  391.         ; Handle rawkey events at the tail of the chain
  392. ih_mrawkey:     bsr     ih_dorawkey             ; Handle event
  393.         bra     ih_mdlink               ; Delink event
  394.  
  395.         ; Handle rawmouse events at the tail of the chain
  396. ih_mrawmouse:   bsr     ih_dorawmouse           ; Handle event
  397.         bra     ih_mdlink               ; Delink event
  398.  
  399. ; -------------------------------------------------------
  400.  
  401. ; Handles rawmouse events
  402. ih_dorawmouse:  move.w  ie_Code(a2),d0
  403.         cmp.w   #IECODE_LBUTTON,d0      ; Test for left button down
  404.         bne     ihrm_nolbdown           ; Skip if not true
  405.         Lea     base(pc),a4
  406.         Move.w  #-1,lbutton-base(a4)    ; Set left button flag
  407.         bra     ihrm_end
  408.  
  409. ihrm_nolbdown:  cmp.w   #IECODE_LBUTTON!IECODE_UP_PREFIX,d0     ; Left button up
  410.         bne     ihrm_nolbup             ; Skip if not true
  411.         Lea     base(pc),a4
  412.         Move.w  #0,lbutton-base(a4)     ; Clear left button flag
  413.         bra     ihrm_end
  414.  
  415. ihrm_nolbup:    cmp.w   #IECODE_RBUTTON,d0      ; Test for right button down
  416.         bne     ihrm_norbdown           ; Skip if not true
  417.         Lea     base(pc),a4
  418.         Move.w  #-1,rbutton-base(a4)    ; Set right button flag
  419.         bra     ihrm_end
  420.  
  421. ihrm_norbdown:  cmp.w   #IECODE_RBUTTON!IECODE_UP_PREFIX,d0     ; Right button up
  422.         bne     ihrm_norbup             ; Skip if not true
  423.         Lea     base(pc),a4
  424.         Move.w  #0,rbutton-base(a4)     ; Clear left button flag
  425.         bra     ihrm_end
  426.  
  427. ihrm_norbup:    cmp.w   #IECODE_MBUTTON,d0      ; Test for middle button down
  428.         bne     ihrm_nombdown           ; Skip if not true
  429.         Lea     base(pc),a4
  430.         Move.w  #-1,mbutton-base(a4)    ; Set middle button flag
  431.         bra     ihrm_end
  432.  
  433. ihrm_nombdown:  cmp.w   #IECODE_MBUTTON!IECODE_UP_PREFIX,d0     ; Middle button up
  434.         bne     ihrm_end                ; Skip if not true
  435.         move.w  #0,mbutton              ; Clear left button flag
  436. ihrm_end:       rts
  437.  
  438. ; -------------------------------------------------------
  439.  
  440. ih_dorawkey:    move.w  ie_Code(a2),d0          ; Get keycode
  441.         and.w   #IECODE_UP_PREFIX,d0    ; Key released?
  442.         Lea     base(pc),a4
  443.         Bne     ihrk_nokey              ; Skip if true
  444.         Move.w  ie_Code(a2),lastkey-base(a4)       ; Store keycode in memory
  445.         Move.w  ie_Qualifier(a2),lastqual-base(a4) ; Store qualifier
  446.         bra     ihrk_end
  447. ihrk_nokey:     Move.w  #0,lastkey-base(a4)     ; Store no key pressed
  448.         Move.w  #0,lastqual-base(a4)
  449. ihrk_end:       Rts
  450. ;;;
  451. ;;; "  ihandler data"
  452. lbutton:        Dc.w    0
  453. mbutton:        dc.w    0
  454. rbutton:        dc.w    0               ; State of mouse buttons
  455. mousex:         dc.w    0
  456. mousey:         dc.w    0               ; Mouse position
  457. lastkey:        dc.w    0               ; Last rawkey code
  458. lastqual:       dc.w    0               ; Last rawkey qualifier
  459.  
  460. mainPort:       Dc.l    0
  461. extIO:          dc.l    0                       ; Extended io request address
  462. inputOpen:      dc.w    0                       ; Input.device open flag
  463. handlerInst:    dc.w    0
  464. inputHandler:   ds.b    IS_SIZE                 ; Input event handler info
  465. nameString:     Dc.b    "PowerL¡ne",0
  466. inputName:      Dc.b    "input.device",0
  467.         even
  468. ;;;
  469.            ENDC
  470.  
  471. ;;; "FixSprites"
  472.  
  473. ; This bit fixes problems with sprites in V39 kickstart
  474. ; it is only called if intuition.library opens, which in this
  475. ; case is only if V39 or higher kickstart is installed. If you
  476. ; require intuition.library you will need to change the
  477. ; openlibrary code to open V33+ Intuition and add a V39 test before
  478. ; calling this code (which is only required for V39+ Kickstart)
  479.  
  480. FixSprites:
  481.     Lea      base(pc),a4
  482.  
  483.     Move.l   _IntBase-base(a4),a6       ; open intuition.library first!
  484.     Lea      wbname(pc),a0
  485.     jsr      _LVOLockPubScreen(a6)
  486.  
  487.     tst.l    d0                         ; Could I lock Workbench?
  488.     beq.s    .error                     ; if not, error
  489.     Move.l   d0,wbscreen-base(a4)
  490.     move.l   d0,a0
  491.  
  492.     move.l   sc_ViewPort+vp_ColorMap(a0),a0
  493.     Lea      taglist(pc),a1
  494.     Move.l   _GfxBase-base(a4),a6       ; open graphics.library first!
  495.     jsr      _LVOVideoControl(a6)       ;
  496.  
  497.     Move.l   resolution-base(a4),oldres-base(a4)    ; store old resolution
  498.  
  499.     Move.l   #SPRITERESN_140NS,resolution-base(a4)
  500.     Move.l   #VTAG_SPRITERESN_SET,taglist-base(a4)
  501.  
  502.     Move.l   wbscreen-base(a4),a0
  503.     move.l   sc_ViewPort+vp_ColorMap(a0),a0
  504.     Lea      taglist(pc),a1
  505.     jsr      _LVOVideoControl(a6)       ; set sprites to lores
  506.  
  507.     Move.l   wbscreen-base(a4),a0
  508.     Move.l   _IntBase-base(a4),a6
  509.     jsr      _LVOMakeScreen(a6)
  510.     jsr      _LVORethinkDisplay(a6)     ; and rebuild system copperlists
  511.  
  512. ; Sprites are now set back to 140ns in a system friendly manner!
  513.  
  514. .error
  515.     rts
  516. ;;;
  517. ;;; "ReturnSprites"
  518. ReturnSprites:
  519. ; If you mess with sprite resolution you must return resolution
  520. ; back to workbench standard on return! This code will do that...
  521.  
  522.     Lea      base(pc),a4
  523.  
  524.     Move.l   wbscreen-base(a4),d0
  525.     beq.s    .error
  526.     move.l   d0,a0
  527.  
  528.     Move.l   oldres-base(a4),resolution-base(a4)          ; change taglist
  529.     Lea      taglist-base(a4),a1
  530.     move.l   sc_ViewPort+vp_ColorMap(a0),a0
  531.     Move.l   _GfxBase-base(a4),a6
  532.     jsr      _LVOVideoControl(a6)       ; return sprites to normal.
  533.  
  534.     Move.l   _IntBase-base(a4),a6
  535.     Move.l   wbscreen-base(a4),a0
  536.     jsr      _LVOMakeScreen(a6)         ; and rebuild screen
  537.     jsr      _LVORethinkDisplay(a6)     ; and rebuild system copperlists
  538.  
  539.     Move.l   wbscreen-base(a4),a1
  540.     sub.l    a0,a0
  541.     jsr      _LVOUnlockPubScreen(a6)
  542.  
  543. .error
  544.     rts
  545.  
  546. wbview          dc.l  0
  547. oldres          dc.l  0
  548. wbscreen        dc.l  0
  549.  
  550. taglist         dc.l  VTAG_SPRITERESN_GET
  551. resolution      dc.l  SPRITERESN_ECS
  552.         dc.l  TAG_DONE,0
  553.  
  554. wbname          dc.b  "Workbench",0
  555. ;;;
  556.  
  557. ;;; "Startup"
  558. _Startup:          Sub.l     a1,a1
  559.            Move.l    (_ExecBase).w,a6
  560.            Jsr       _LVOFindTask(a6)
  561.            Move.l    d0,a4
  562.  
  563.            Tst.l     pr_CLI(a4)           ; was it called from CLI?
  564.            Bne.s     .skip                ; if so, skip this bit...
  565.  
  566.            Lea       pr_MsgPort(a4),a0
  567.            Move.l    (_ExecBase).w,a6
  568.            Jsr       _LVOWaitPort(a6)
  569.            Lea       pr_MsgPort(a4),a0
  570.            Jsr       _LVOGetMsg(a6)
  571.  
  572.  
  573.            Lea      base(pc),a4
  574.            Move.l    d0,returnMsg-base(a4)
  575.  
  576. .skip              Rts
  577.  
  578. returnMsg:         Dc.l      0
  579.  
  580. ;;;
  581. ;;; "Closedown"
  582. _Closedown:        Lea     base(pc),a4
  583.            Tst.l   returnMsg-base(a4)      ; Is there a message?
  584.            Beq.s   .skip                   ; if not, skip...
  585.  
  586.            Move.l  (_ExecBase).w,a6
  587.            Jsr     _LVOForbid(a6)          ; note! No Permit needed!
  588.  
  589.            Move.l  returnMsg(pc),a1
  590.            Jsr     _LVOReplyMsg(a6)
  591.  
  592. .skip              Rts
  593. ;;;
  594.  
  595. ;;; "Initdemo"
  596. _InitDemo:         Movem.l   d1-d7/a0-a6,-(a7)
  597.            Bsr       CPUTest
  598.            Cmp.w     #20,d0
  599.            Blt       .BadCPU
  600.  
  601.            Bsr       CheckRev
  602.            Cmp.w     #39,d0              ;Lower than 39?
  603.            Blt       .LowRevision        ;Then branch!
  604.  
  605.            Bsr       OpenLibs            ;Else OpenLibs.
  606.  
  607.            Bsr       AGATest
  608.            Tst.l     d0
  609.            Beq       .BadChipset
  610.  
  611.            ;Bsr       CheckFastMem
  612.  
  613.            ;Bsr       InstallIH
  614.            ;Tst.l     d0
  615.            ;Bne       .NoHandler
  616.  
  617.            Bsr       FixSprites
  618.  
  619.            Bsr       GetVBR
  620.            Bsr       BoostCaches
  621.  
  622.            Bsr       KillSystem
  623.            Bsr       SaveView
  624.  
  625.            Move.l    _VBR,a0
  626.            Move.l    $6c(a0),OldLev3
  627.            Move.l    #DummyLev3,$6c(a0)
  628.  
  629.            Movem.l   (a7)+,d1-d7/a0-a6
  630.            Moveq     #0,d0
  631.            Rts
  632.  
  633. .BadCPU            Movem.l   (a7)+,d1-d7/a0-a6
  634.            Moveq     #1,d0
  635.            Rts
  636.  
  637. .LowRevision       Movem.l   (a7)+,d1-d7/a0-a6
  638.            Moveq     #1,d0
  639.            Rts
  640.  
  641. .BadChipset        Bsr       CloseLibs
  642.            Movem.l   (a7)+,d1-d7/a0-a6
  643.            Moveq     #1,d0
  644.            Rts
  645.  
  646. .NoHandler         Bsr       CloseLibs
  647.            Movem.l   (a7)+,d1-d7/a0-a6
  648.            Moveq     #1,d0
  649.            Rts
  650.  
  651. ;;;
  652. ;;; "UninitDemo"
  653. _UninitDemo:       Movem.l   d0-d7/a0-a6,-(a7)
  654.            Move.l    _VBR,a0
  655.            Move.l    OldLev3,$6c(a0)
  656.  
  657.            Bsr       ReturnSprites
  658.            Bsr       RestoreView
  659.  
  660.            Bsr       FreeSystem
  661.  
  662.            Bsr       RestoreCaches
  663.  
  664.            ;Move.l    _DosBase,a6
  665.            ;Move.l    #50,d1
  666.            ;Jsr       _LVODelay(a6)       ;Wait for inputhandler
  667.                          ;to do its work!
  668.  
  669.            ;Bsr       RemoveIH
  670.  
  671.            Bsr       CloseLibs           ;Close Down libraries.
  672.            Movem.l   (a7)+,d0-d7/a0-a6
  673.            Rts
  674. ;;;
  675.  
  676. ;;; "PlayMusic"
  677. _PlayMusic:        Movem.l   d1-d7/a0-a6,-(a7)
  678.  
  679.            Bsr       _Sync
  680.            Move.w    #$0020,$dff09a
  681.  
  682.  
  683.            Lea       P61_data,a0     ;Module
  684.            Sub.l     a1,a1           ;No separate samples
  685.            Lea       samples,a2      ;Sample buffer
  686.  
  687.            Moveq     #0,d0           ;Auto Detect
  688.            Bsr       P61_Init
  689.  
  690.            Move.w    #$8020,$dff09a
  691.  
  692.            Movem.l   (a7)+,d1-d7/a0-a6
  693.            Rts
  694. ;;;
  695. ;;; "StopMusic"
  696. _StopMusic:        Movem.l   d0-d7/a0-a6,-(a7)
  697.  
  698.            Lea       Custom,a6
  699.            Bsr       P61_End
  700.  
  701.            Movem.l   (a7)+,d0-d7/a0-a6
  702.            Rts
  703. ;;;
  704.  
  705.            IFD       kulig
  706. ;;; "CheckFastMem"
  707. **************************************************************
  708. * Tests if Fastmem is available. Result stored in _Fastmem.  *
  709. *                                                            *
  710. * IN:              VOID                                      *
  711. * OUT:             d0 - Result:                              *
  712. *                       0 = No fastmem                       *
  713. *                       1 = Fastmem                          *
  714. **************************************************************
  715.  
  716. CheckFastMem:      Move.l    _ExecBase,a6
  717.            Lea       base(pc),a4
  718.            Move.l    #MEMF_FAST,d1
  719.            Jsr       _LVOAvailMem(a6)
  720.            Tst.l     d0
  721.            Beq       .nofast
  722.  
  723.            Moveq     #1,d0
  724.            Move.w    d0,_FastMem-base(a4)
  725.            Rts
  726.  
  727. .nofast            Moveq     #0,d0
  728.            Move.w    d0,_FastMem-base(a4)
  729.            Rts
  730.  
  731. ;;;
  732.            ENDC
  733.  
  734. ;;; "CPUTest"
  735. **************************************************************
  736. * Checks which CPU is fitted. Result stored in _CPU.         *
  737. *                                                            *
  738. * IN:              VOID                                      *
  739. * OUT:             d0 - Type of CPU:                         *
  740. *                       0 = 68000                            *
  741. *                       10 = 68010                           *
  742. *                       20 = 68020                           *
  743. *                       30 = 68030                           *
  744. *                       40 = 68040                           *
  745. **************************************************************
  746.  
  747. CPUTest:           Move.l    _ExecBase,a6
  748.            Lea       base(pc),a4
  749.            Move.w    AttnFlags(a6),d0
  750.            Btst      #AFB_68040,d0
  751.            Bne       .CPU040
  752.            Btst      #AFB_68030,d0
  753.            Bne       .CPU030
  754.            Btst      #AFB_68020,d0
  755.            Bne       .CPU020
  756.            Btst      #AFB_68010,d0
  757.            Bne       .CPU010
  758.  
  759. .CPU000:           Moveq     #0,d0
  760.            Move.w    d0,_CPU-base(a4)
  761.            Rts
  762.  
  763. .CPU010:           Moveq     #10,d0
  764.            Move.w    d0,_CPU-base(a4)
  765.            Rts
  766.  
  767. .CPU020:           Moveq     #20,d0
  768.            Move.w    d0,_CPU-base(a4)
  769.            Rts
  770.  
  771. .CPU030:           Moveq     #30,d0
  772.            Move.w    d0,_CPU-base(a4)
  773.            Rts
  774.  
  775. .CPU040:           Moveq     #40,d0
  776.            Move.w    d0,_CPU-base(a4)
  777.            Rts
  778.  
  779. ;;;
  780. ;;; "AGATest"
  781. **************************************************************
  782. * Checks if machine is equipped with AGA-circuits. Needs     *
  783. * _GfxBase.                                                  *
  784. *                                                            *
  785. * IN:              VOID                                      *
  786. * OUT              d0 - Result:                              *
  787. *                       0 = No AGA                           *
  788. *                       1 = AGA                              *
  789. **************************************************************
  790.  
  791. AGATest:
  792.            Lea       base(pc),a4
  793.            Move.l    _GfxBase-base(a4),a6
  794.            Move.b    gb_ChipRevBits0(a6),d0
  795.            And.b     #GFXF_AA_ALICE!GFXF_AA_LISA,d0
  796.            Cmp.b     #GFXF_AA_ALICE!GFXF_AA_LISA,d0
  797.            Bne       .NoAGA
  798.  
  799.            Moveq     #1,d0
  800.            Move.w    d0,_AGA
  801.            Rts
  802.  
  803. .NoAGA:            Moveq     #0,d0
  804.            Move.w    d0,_AGA
  805.            Rts
  806.  
  807. ;;;
  808. ;;; "CheckRev"
  809. **************************************************************
  810. * Checks your OS revision.                                   *
  811. *                                                            *
  812. * IN:              VOID                                      *
  813. * OUT:             d0 - Revision                             *
  814. **************************************************************
  815.  
  816. CheckRev:          Move.l    _ExecBase,a6         ;Get Exec structure.
  817.            Move.w    LIB_VERSION(a6),d0  ;Get OS-Revision.
  818.            Lea       base(pc),a4
  819.            Move.w    d0,_OS-base(a4)
  820.  
  821.            Rts
  822. ;;;
  823.  
  824. ;;; "OpenLibs"
  825. **************************************************************
  826. * Opens graphics, dos and intuition.library.                 *
  827. * Does NOT test if succed. (Requires that you have tested    *
  828. * (LIB_VERSION=>39) before calling this routine.             *
  829. *                                                            *
  830. * IN:              VOID                                      *
  831. * OUT:             VOID                                      *
  832. **************************************************************
  833.  
  834. OpenLibs:          Move.l    _ExecBase,a6         ;Get Exec structure.
  835.            Lea       base(pc),a4
  836.  
  837.            Lea       Dosname(pc),a1          ;Point at string.
  838.            Move.l    #39,d0              ;Lowest version.
  839.            Jsr       _LVOOpenLibrary(a6) ;Open dos.library.
  840.            Move.l    d0,_DosBase-base(a4)         ;Save basepointer.
  841.  
  842.            Lea       Gfxname(pc),a1          ;Point at string.
  843.            Move.l    #39,d0              ;Lowest version.
  844.            Jsr       _LVOOpenLibrary(a6) ;Open graphics.library.
  845.            Move.l    d0,_GfxBase-base(a4)         ;Save basepointer.
  846.  
  847.            Lea       Intname(pc),a1          ;Point at string.
  848.            Move.l    #39,d0              ;Lowest version.
  849.            Jsr       _LVOOpenLibrary(a6) ;Open intuition.library.
  850.            Move.l    d0,_IntBase-base(a4)         ;Save basepointer.
  851.  
  852.            Rts
  853. ;;;
  854. ;;; "CloseLibs"
  855. **************************************************************
  856. * Closes the 3 librarys, previously opened by 'OpenLibs'     *
  857. *                                                            *
  858. * IN:              VOID                                      *
  859. * OUT:             VOID                                      *
  860. **************************************************************
  861.  
  862. CloseLibs:         Move.l    _ExecBase,a6
  863.            Lea       base(pc),a4
  864.  
  865.            Move.l    _DosBase-base(a4),a1
  866.            Jsr       _LVOCloseLibrary(a6)
  867.  
  868.            Move.l    _GfxBase-base(a4),a1
  869.            Jsr       _LVOCloseLibrary(a6)
  870.  
  871.            Move.l    _IntBase-base(a4),a1
  872.            Jsr       _LVOCloseLibrary(a6)
  873.  
  874.            Rts
  875. ;;;
  876.  
  877. ;;; "SaveView (And DMA)"
  878. **************************************************************
  879. * Saves old view and inits a new one. Needs _GfxBase.        *
  880. *                                                            *
  881. * IN:              VOID                                      *
  882. * OUT:             VOID                                      *
  883. **************************************************************
  884.  
  885. SaveView:
  886.            Lea       base(pc),a4
  887.            Move.l    _GfxBase-base(a4),a6
  888.            Lea       Custom,a5
  889.  
  890.            Move.l    gb_ActiView(a6),OldView-base(a4)
  891.            Move.l    gb_copinit(a6),OldCop-base(a4)
  892.  
  893.            Move.w    dmaconr(a5),OldDMA-base(a4)
  894.            Move.w    #(DMAF_SPRITE!DMAF_COPPER!DMAF_RASTER),dmacon(a5)
  895.  
  896.            Sub.l     a1,a1
  897.            Jsr       _LVOLoadView(a6)
  898.            Jsr       _LVOWaitTOF(a6)
  899.            Jsr       _LVOWaitTOF(a6)
  900.  
  901.            Lea       DummyCopper,a0
  902.            Move.l    a0,cop1lc(a5)
  903.            Move.w    #0,copjmp1(a5)
  904.  
  905.            Move.w    #(DMAF_SETCLR!DMAF_COPPER!DMAF_MASTER),dmacon(a5)
  906.  
  907.            Rts
  908. ;;;
  909. ;;; "RestoreView (And DMA)"
  910. **************************************************************
  911. * Restores old view. Needs _GfxBase.                         *
  912. *                                                            *
  913. * IN:              VOID                                      *
  914. * OUT:             VOID                                      *
  915. **************************************************************
  916.  
  917. RestoreView:       Lea       base(pc),a4
  918.            Lea       Custom,a5
  919.            Move.l    _GfxBase-base(a4),a6
  920.  
  921.            Move.w    #(DMAF_SPRITE!DMAF_COPPER!DMAF_RASTER),dmacon(a5)
  922.  
  923.            Move.l    OldView-base(a4),a1
  924.            Jsr       _LVOLoadView(a6)
  925.            Jsr       _LVOWaitTOF(a6)
  926.            Jsr       _LVOWaitTOF(a6)
  927.  
  928.            Move.l    OldCop-base(a4),cop1lc(a5)
  929.            Move.w    #0,copjmp1(a5)
  930.  
  931.            Move.w    OldDMA-base(a4),d0
  932.            Bset      #15,d0
  933.            Move.w    d0,dmacon(a5)
  934.  
  935.            Rts
  936. ;;;
  937.  
  938. ;;; "KillSystem"
  939. KillSystem:        Lea       Custom,a5
  940.            Move.l    _ExecBase,a6
  941.            Lea       base(pc),a4
  942.  
  943.            Sub.l     a1,a1
  944.            Jsr       _LVOFindTask(a6)
  945.            Move.l    d0,a1
  946.            Moveq     #127,d0
  947.            Jsr       _LVOSetTaskPri(a6)
  948.            Move.b    d0,OldPri-base(a4)
  949.  
  950.            Jsr       _LVOForbid(a6)              ;Forbid MT
  951.  
  952.            Lea       Custom,a5                   ;Disable Interrupts
  953.            Move.w    intenar(a5),OldInt-base(a4)
  954.            ;Move.w    #$7fff,intena(a5)
  955.            ;Jsr       _LVODisable(a6)
  956.            ;Move.w    #$ffff,intreq(a5)
  957.  
  958.            Move.l    _GfxBase-base(a4),a6
  959.            Jsr       _LVOWaitBlit(a6)
  960.            Jsr       _LVOOwnBlitter(a6)
  961.  
  962.            Rts
  963. ;;;
  964. ;;; "FreeSystem"
  965. FreeSystem:        Lea       Custom,a5
  966.            Lea       base(pc),a4
  967.  
  968.            Move.l    _GfxBase-base(a4),a6
  969.            Jsr       _LVOWaitBlit(a6)
  970.            Jsr       _LVODisownBlitter(a6)
  971.  
  972.            Move.w    OldInt-base(a4),d7
  973.            Bset      #15,d7
  974.            Move.w    #$7fff,intena(a5)
  975.            Move.w    d7,intena(a5)
  976.  
  977.            Move.l    _ExecBase,a6
  978.            ;Jsr       _LVOEnable(a6)
  979.  
  980.            Jsr       _LVOPermit(a6)
  981.  
  982.            Sub.l     a1,a1
  983.            Jsr       _LVOFindTask(a6)
  984.            Move.l    d0,a1
  985.            Move.b    OldPri-base(a4),d0
  986.            Ext.w     d0
  987.            Ext.l     d0
  988.            Jsr       _LVOSetTaskPri(a6)
  989.  
  990.            Rts
  991. ;;;
  992.  
  993. ;;; "BoostCaches"
  994. BoostCaches:
  995.            Move.l    _ExecBase,a6
  996.            Move.l    #CACRF_EnableI!CACRF_IBE!CACRF_EnableD!CACRF_DBE,d0
  997.            Move.l    #CACRF_EnableI!CACRF_IBE!CACRF_EnableD!CACRF_DBE,d1
  998.            Jsr       _LVOCacheControl(a6)
  999.            Lea       base(pc),a4
  1000.            Move.l    d0,OldCache-base(a4)
  1001.  
  1002.            Rts
  1003. ;;;
  1004. ;;; "RestoreCaches"
  1005. RestoreCaches:
  1006.            Move.l    _ExecBase,a6
  1007.            Lea       base(pc),a4
  1008.            Move.l    OldCache-base(a4),d0
  1009.            Move.l    #$ffffffff,d1
  1010.            Jsr       _LVOCacheControl(a6)
  1011.  
  1012.            Rts
  1013. ;;;
  1014.  
  1015. ;;; "GetVBR"
  1016. GetVBR:            Move.l    _ExecBase,a6
  1017.            Lea       get_VBR(pc),a5
  1018.            Jsr       _LVOSupervisor(a6)
  1019.            Lea       base(pc),a4
  1020.            Move.l    a0,_VBR-base(a4)
  1021.            Rts
  1022. ;;;
  1023.  
  1024. ;;; "Variables"
  1025. base:
  1026. _GfxBase:          Dc.l      0
  1027. _IntBase:          Dc.l      0
  1028. _DosBase:          Dc.l      0
  1029.  
  1030. OldView:           Dc.l      0
  1031. OldCop:            Dc.l      0
  1032. OldInt:            Dc.w      0
  1033. OldDMA             Dc.w      0
  1034. OldPri:            Dc.w      0
  1035. OldCache:          Dc.l      0
  1036. OldLev3:           Dc.l      0
  1037.  
  1038. WindowPtr:         Dc.l      0
  1039.  
  1040. Gfxname:           Dc.b      'graphics.library',0
  1041. Intname:           Dc.b      'intuition.library',0
  1042. Dosname:           Dc.b      'dos.library',0        
  1043.            Even
  1044.  
  1045. _FastMem:          Dc.w      0
  1046. _CPU:              Dc.w      0
  1047. _AGA:              Dc.w      0
  1048. _OS:               Dc.w      0
  1049. _VBR:              Dc.l      0
  1050.  
  1051. SyncBit:           Dc.w      0
  1052. ;;;
  1053. ;;; "get_VBR exception"
  1054. get_VBR:           Movec.l   VBR,a0
  1055.            Nop
  1056.            Rte
  1057. ;;;
  1058. ;;; "DummyLev3"
  1059. DummyLev3:         Btst      #5,$dff01f
  1060.            Beq       .novblreq
  1061.  
  1062.            Move.w    #1,SyncBit
  1063. .novblreq          Move.w    #%1110000,$dff09c
  1064.            Nop
  1065.            Rte
  1066. ;;;
  1067.  
  1068. ;;; "The Player 6.1A code"
  1069. *********************************
  1070. *        Player 6.1A ®          *
  1071. *      All in one-version       *
  1072. *        Version 610.2          *
  1073. *   © 1992-95 Jarno Paananen    *
  1074. *     All rights reserved       *
  1075. *********************************
  1076.  
  1077.  
  1078. ******** START OF BINARY FILE **************
  1079.  
  1080. P61_motuuli
  1081.     bra.w   P61_Init
  1082.     ifeq    CIA
  1083.     bra.w   P61_Music
  1084.     else
  1085.     rts
  1086.     rts
  1087.     endc
  1088.     bra.w   P61_End
  1089.     rts                             ;no P61_SetRepeat
  1090.     rts
  1091.     bra.w   P61_SetPosition
  1092.  
  1093. P61_Master      dc      64              ;Master volume (0-64)
  1094. P61_Tempo       dc      1               ;Use tempo? 0=no,non-zero=yes
  1095. P61_Play        dc      1               ;Stop flag (0=stop)
  1096. P61_E8          dc      0               ;Info nybble after command E8
  1097. P61_VBR         dc.l    0               ;If you're using non-valid execbase
  1098.                     ;put VBR here! (Otherwise 0 assumed)
  1099.                     ;You can also get VBR from here, if
  1100.                     ;using exec-valid version
  1101.  
  1102. P61_Pos         dc      0               ;Current song position
  1103. P61_Patt        dc      0               ;Current pattern
  1104. P61_CRow        dc      0               ;Current pattern row
  1105.  
  1106. P61_Temp0Offset
  1107.     dc.l    P61_temp0-P61_motuuli
  1108. P61_Temp1Offset
  1109.     dc.l    P61_temp1-P61_motuuli
  1110. P61_Temp2Offset
  1111.     dc.l    P61_temp2-P61_motuuli
  1112. P61_Temp3Offset
  1113.     dc.l    P61_temp3-P61_motuuli
  1114.  
  1115. P61_getnote     macro
  1116.     moveq   #$7e,d0
  1117.     and.b   (a5),d0
  1118.     beq.b   .nonote
  1119.     ifne    P61_vib
  1120.     clr.b   P61_VibPos(a5)
  1121.     endc
  1122.     ifne    P61_tre
  1123.     clr.b   P61_TrePos(a5)
  1124.     endc
  1125.  
  1126.     ifne    P61_ft
  1127.     add     P61_Fine(a5),d0
  1128.     endc
  1129.     move    d0,P61_Note(a5)
  1130.     move    (a2,d0),P61_Period(a5)
  1131.  
  1132. .nonote
  1133.     endm
  1134.  
  1135.     ifeq    system
  1136.     ifne    CIA
  1137. P61_intti
  1138.     movem.l d0-a6,-(sp)
  1139.     tst.b   $bfdd00
  1140.     lea     $dff000,a6
  1141.     move    #$2000,$9c(a6)
  1142.     ;move    #$fff,$180(a6)
  1143.     bsr     P61_Music
  1144.     ;move    #0,$180(a6)
  1145.     movem.l (sp)+,d0-a6
  1146.     nop
  1147.     rte
  1148.     endc
  1149.     endc
  1150.  
  1151.     ifne    system
  1152. P61_lev6server
  1153.     movem.l d2-d7/a2-a6,-(sp)
  1154.     lea     P61_timeron(pc),a0
  1155.     tst     (a0)
  1156.     beq.b   P61_ohi
  1157.  
  1158.     lea     $dff000,a6
  1159.     move    P61_server(pc),d0
  1160.     beq.b   P61_musica
  1161.     subq    #1,d0
  1162.     beq     P61_dmason
  1163.     bra     P61_setrepeat
  1164.  
  1165. P61_musica
  1166.     bsr     P61_Music
  1167.  
  1168. P61_ohi movem.l (sp)+,d2-d7/a2-a6
  1169.     moveq   #1,d0
  1170.     rts
  1171.     endc
  1172.  
  1173. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1174. ;­ Call P61_Init to initialize the playroutine  ­
  1175. ;­ D0 --> Timer detection (for CIA-version)     ­
  1176. ;­ A0 --> Address to the module                 ­
  1177. ;­ A1 --> Address to samples/0 if in the module ­
  1178. ;­ A2 --> Address to sample buffer              ­
  1179. ;­ D0 <-- 0 if succeeded                        ­
  1180. ;­ A6 <-- $DFF000                               ­
  1181. ;­              Uses D0-A6                      ­
  1182. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1183.  
  1184. P61_Init
  1185.     cmp.l   #"P61A",(a0)+
  1186.     beq.b   .modok
  1187.     subq.l  #4,a0
  1188.  
  1189. .modok
  1190.     ifne    CIA
  1191.     move    d0,-(sp)
  1192.     endc
  1193.  
  1194.     moveq   #0,d0
  1195.     cmp.l   d0,a1
  1196.     bne.b   .redirect
  1197.  
  1198.     move    (a0),d0
  1199.     lea     (a0,d0.l),a1
  1200. .redirect
  1201.     move.l  a2,a6
  1202.     lea     8(a0),a2
  1203.     moveq   #$40,d0
  1204.     and.b   3(a0),d0
  1205.     bne.b   .buffer
  1206.     move.l  a1,a6
  1207.     subq.l  #4,a2
  1208. .buffer
  1209.  
  1210.     lea     P61_cn(pc),a3
  1211.     moveq   #$1f,d1
  1212.     and.b   3(a0),d1
  1213.     move.l  a0,-(sp)
  1214.     lea     P61_samples(pc),a4
  1215.     subq    #1,d1
  1216.     moveq   #0,d4
  1217. P61_lopos
  1218.     move.l  a6,(a4)+
  1219.     move    (a2)+,d4
  1220.     bpl.b   P61_kook
  1221.     neg     d4
  1222.     lea     P61_samples-16(pc),a5
  1223.     ifeq    opt020
  1224.     asl     #4,d4
  1225.     move.l  (a5,d4),d6
  1226.     else
  1227.     add     d4,d4
  1228.     move.l  (a5,d4*8),d6
  1229.     endc
  1230.     move.l  d6,-4(a4)
  1231.     move    4(a5,d4),d4
  1232.     sub.l   d4,a6
  1233.     sub.l   d4,a6
  1234.     bra.b   P61_jatk
  1235.  
  1236. P61_kook
  1237.     move.l  a6,d6
  1238.     tst.b   3(a0)
  1239.     bpl.b   P61_jatk
  1240.  
  1241.     tst.b   (a2)
  1242.     bmi.b   P61_jatk
  1243.  
  1244.     move    d4,d0
  1245.     subq    #2,d0
  1246.     bmi.b   P61_jatk
  1247.  
  1248.     move.l  a1,a5
  1249.     move.b  (a5)+,d2
  1250.     sub.b   (a5),d2
  1251.     move.b  d2,(a5)+
  1252. .loop   sub.b   (a5),d2
  1253.     move.b  d2,(a5)+
  1254.     sub.b   (a5),d2
  1255.     move.b  d2,(a5)+
  1256.     dbf     d0,.loop
  1257.  
  1258. P61_jatk
  1259.     move    d4,(a4)+
  1260.     moveq   #0,d2
  1261.     move.b  (a2)+,d2
  1262.     moveq   #0,d3
  1263.     move.b  (a2)+,d3
  1264.  
  1265.     moveq   #0,d0
  1266.     move    (a2)+,d0
  1267.     bmi.b   .norepeat
  1268.  
  1269.     move    d4,d5
  1270.     sub     d0,d5
  1271.     move.l  d6,a5
  1272.  
  1273.     add.l   d0,a5
  1274.     add.l   d0,a5
  1275.  
  1276.     move.l  a5,(a4)+
  1277.     move    d5,(a4)+
  1278.     bra.b   P61_gene
  1279. .norepeat
  1280.     move.l  d6,(a4)+
  1281.     move    #1,(a4)+
  1282. P61_gene
  1283.     move    d3,(a4)+
  1284.     moveq   #$f,d0
  1285.     and     d2,d0
  1286.     mulu    #74,d0
  1287.     move    d0,(a4)+
  1288.  
  1289.     tst     -6(a2)
  1290.     bmi.b   .nobuffer
  1291.  
  1292.     moveq   #$40,d0
  1293.     and.b   3(a0),d0
  1294.     beq.b   .nobuffer
  1295.  
  1296.     move    d4,d7
  1297.     tst.b   d2
  1298.     bpl.b   .copy
  1299.  
  1300.     subq    #1,d7
  1301.     moveq   #0,d5
  1302.     moveq   #0,d4
  1303. .lo     move.b  (a1)+,d4
  1304.     moveq   #$f,d3
  1305.     and     d4,d3
  1306.     lsr     #4,d4
  1307.  
  1308.     sub.b   .table(pc,d4),d5
  1309.     move.b  d5,(a6)+
  1310.     sub.b   .table(pc,d3),d5
  1311.     move.b  d5,(a6)+
  1312.     dbf     d7,.lo
  1313.     bra.b   .kop
  1314.  
  1315. .copy   add     d7,d7
  1316.     subq    #1,d7
  1317. .cob    move.b  (a1)+,(a6)+
  1318.     dbf     d7,.cob
  1319.     bra.b   .kop
  1320.  
  1321. .table dc.b     0,1,2,4,8,16,32,64,128,-64,-32,-16,-8,-4,-2,-1
  1322.  
  1323. .nobuffer
  1324.     move.l  d4,d6
  1325.     add.l   d6,d6
  1326.     add.l   d6,a6
  1327.     add.l   d6,a1
  1328. .kop    dbf     d1,P61_lopos
  1329.  
  1330.     move.l  (sp)+,a0
  1331.     and.b   #$7f,3(a0)
  1332.  
  1333.     move.l  a2,-(sp)
  1334.  
  1335.     lea     P61_temp0(pc),a1
  1336.     lea     P61_temp1(pc),a2
  1337.     lea     P61_temp2(pc),a4
  1338.     lea     P61_temp3(pc),a5
  1339.     moveq   #Channel_Block_SIZE/2-2,d0
  1340.  
  1341.     moveq   #0,d1
  1342. .cl     move    d1,(a1)+
  1343.     move    d1,(a2)+
  1344.     move    d1,(a4)+
  1345.     move    d1,(a5)+
  1346.     dbf     d0,.cl
  1347.  
  1348.     lea     P61_temp0-P61_cn(a3),a1
  1349.     lea     P61_emptysample-P61_cn(a3),a2
  1350.     moveq   #channels-1,d0
  1351. .loo    move.l  a2,P61_Sample(a2)
  1352.     dbf     d0,.loo
  1353.  
  1354.     move.l  (sp)+,a2
  1355.     move.l  a2,P61_positionbase-P61_cn(a3)
  1356.  
  1357.     moveq   #$7f,d1
  1358.     and.b   2(a0),d1
  1359.  
  1360.     ifeq    opt020
  1361.     lsl     #3,d1
  1362.     lea     (a2,d1.l),a4
  1363.     else
  1364.     lea     (a2,d1.l*8),a4
  1365.     endc
  1366.     move.l  a4,P61_possibase-P61_cn(a3)
  1367.  
  1368.     move.l  a4,a1
  1369.     moveq   #-1,d0
  1370. .search cmp.b   (a1)+,d0
  1371.     bne.b   .search
  1372.     move.l  a1,P61_patternbase-P61_cn(a3)   
  1373.     move.l  a1,d0
  1374.     sub.l   a4,d0
  1375.     move    d0,P61_slen-P61_cn(a3)
  1376.  
  1377.     ifd     start
  1378.     lea     start(a4),a4
  1379.     endc
  1380.  
  1381.     moveq   #0,d0
  1382.     move.b  (a4)+,d0
  1383.     move.l  a4,P61_spos-P61_cn(a3)
  1384.     lsl     #3,d0
  1385.     add.l   d0,a2
  1386.  
  1387.     move.l  a1,a4
  1388.     moveq   #0,d0   
  1389.     move    (a2)+,d0
  1390.     lea     (a4,d0.l),a1
  1391.     move.l  a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  1392.     move    (a2)+,d0
  1393.     lea     (a4,d0.l),a1
  1394.     move.l  a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  1395.     move    (a2)+,d0
  1396.     lea     (a4,d0.l),a1
  1397.     move.l  a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  1398.     move    (a2)+,d0
  1399.     lea     (a4,d0.l),a1
  1400.     move.l  a1,P61_ChaPos+P61_temp3-P61_cn(a3)
  1401.  
  1402.     lea     P61_setrepeat(pc),a0
  1403.     move.l  a0,P61_intaddr-P61_cn(a3)
  1404.  
  1405.     move    #63,P61_rowpos-P61_cn(a3)
  1406.     move    #6,P61_speed-P61_cn(a3)
  1407.     move    #5,P61_speed2-P61_cn(a3)
  1408.     clr     P61_speedis1-P61_cn(a3)
  1409.  
  1410.     ifne    P61_pl
  1411.     clr.l   P61_plcount-P61_cn(a3)
  1412.     endc
  1413.  
  1414.     ifne    P61_pde
  1415.     clr     P61_pdelay-P61_cn(a3)
  1416.     clr     P61_pdflag-P61_cn(a3)
  1417.     endc
  1418.     clr     (a3)
  1419.  
  1420.     moveq   #2,d0
  1421.     and.b   $bfe001,d0
  1422.     move.b  d0,P61_ofilter-P61_cn(a3)
  1423.     bset    #1,$bfe001
  1424.  
  1425.     ifeq    system
  1426.     ifne    exec
  1427.     move.l  4.w,a6
  1428.     moveq   #0,d0
  1429.     btst    d0,297(a6)
  1430.     beq.b   .no68010
  1431.  
  1432.     lea     P61_liko(pc),a5
  1433.     jsr     -$1e(a6)
  1434.  
  1435. .no68010
  1436.     move.l  d0,P61_VBR-P61_cn(a3)
  1437.     endc
  1438.  
  1439.     move.l  P61_VBR-P61_cn(a3),a0
  1440.     lea     $78(a0),a0
  1441.     move.l  a0,P61_vektori-P61_cn(a3)
  1442.  
  1443.     move.l  (a0),P61_oldlev6-P61_cn(a3)
  1444.     lea     P61_dmason(pc),a1
  1445.     move.l  a1,(a0)
  1446.     endc
  1447.  
  1448.     moveq   #0,d0
  1449.     lea     $dff000,a6
  1450.     move    d0,$a8(a6)
  1451.     move    d0,$b8(a6)
  1452.     move    d0,$c8(a6)
  1453.     move    d0,$d8(a6)
  1454.     move    #$f,$96(a6)
  1455.  
  1456.     ifeq    system
  1457.     lea     P61_dmason(pc),a1
  1458.     move.l  a1,(a0)
  1459.     move    #$2000,$9a(a6)      ;!*! Av med external interrupt
  1460.     lea     $bfd000,a0
  1461.     lea     P61_timers(pc),a1
  1462.     move.b  #$7f,$d00(a0)
  1463.     move.b  #$10,$e00(a0)
  1464.     move.b  #$10,$f00(a0)
  1465.     move.b  $400(a0),(a1)+
  1466.     move.b  $500(a0),(a1)+
  1467.     move.b  $600(a0),(a1)+
  1468.     move.b  $700(a0),(a1)
  1469.     endc
  1470.  
  1471.     ifeq    system!CIA
  1472.     move.b  #$82,$d00(a0)
  1473.     endc
  1474.  
  1475.     ifne    CIA
  1476.     move    (sp)+,d0
  1477.     subq    #1,d0
  1478.     beq.b   P61_ForcePAL
  1479.     subq    #1,d0
  1480.     beq.b   P61_NTSC
  1481.     ifne    exec
  1482.     move.l  4.w,a1
  1483.     cmp.b   #60,$213(a1)    ;PowerSupplyFrequency
  1484.     beq.b   P61_NTSC
  1485.     endc
  1486. P61_ForcePAL
  1487.     move.l  #1773447,d0     ;PAL
  1488.     bra.b   P61_setcia
  1489. P61_NTSC
  1490.     move.l  #1789773,d0     ;NTSC
  1491. P61_setcia
  1492.     move.l  d0,P61_timer-P61_cn(a3)
  1493.     divu    #125,d0
  1494.     move    d0,P61_thi2-P61_cn(a3)
  1495.     sub     #$1f0*2,d0
  1496.     move    d0,P61_thi-P61_cn(a3)
  1497.  
  1498.     ifeq    system
  1499.     move    P61_thi2-P61_cn(a3),d0
  1500.     move.b  d0,$400(a0)
  1501.     lsr     #8,d0
  1502.     move.b  d0,$500(a0)
  1503.     lea     P61_intti(pc),a1
  1504.     move.l  a1,P61_tintti-P61_cn(a3)
  1505.     move.l  P61_vektori(pc),a2
  1506.     move.l  a1,(a2)
  1507.     move.b  #$83,$d00(a0)
  1508.     move.b  #$11,$e00(a0)
  1509.     endc
  1510.     endc
  1511.  
  1512.     ifeq    system
  1513.     move    #$e000,$9a(a6)
  1514.     moveq   #0,d0
  1515.     rts
  1516.  
  1517.     ifne    exec
  1518. P61_liko
  1519.     dc.l    $4E7A0801               ;MOVEC  VBR,d0
  1520.     rte
  1521.     endc
  1522.     endc
  1523.  
  1524.     ifne    system
  1525.     move.l  a6,-(sp)
  1526.  
  1527.     ifne    CIA
  1528.     clr     P61_server-P61_cn(a3)
  1529.     else
  1530.     move    #1,P61_server-P61_cn(a3)
  1531.     endc
  1532.  
  1533.     move.l  4.w,a6
  1534.     moveq   #-1,d0
  1535.     jsr     -$14a(a6)
  1536.     move.b  d0,P61_sigbit-P61_cn(a3)
  1537.     bmi     P61_err
  1538.  
  1539.     lea     P61_allocport(pc),a1
  1540.     move.l  a1,P61_portti-P61_cn(a3)
  1541.     move.b  d0,15(a1)
  1542.     move.l  a1,-(sp)
  1543.     suba.l  a1,a1
  1544.     jsr     -$126(a6)
  1545.     move.l  (sp)+,a1
  1546.     move.l  d0,16(a1)
  1547.     lea     P61_reqlist(pc),a0
  1548.     move.l  a0,(a0)
  1549.     addq.l  #4,(a0)
  1550.     clr.l   4(a0)
  1551.     move.l  a0,8(a0)
  1552.  
  1553.     lea     P61_dat(pc),a1
  1554.     move.l  a1,P61_reqdata-P61_cn(a3)
  1555.     lea     P61_allocreq(pc),a1
  1556.     lea     P61_audiodev(pc),a0
  1557.     moveq   #0,d0
  1558.     moveq   #0,d1
  1559.     jsr     -$1bc(a6)
  1560.     tst.l   d0
  1561.     bne     P61_err
  1562.     st.b    P61_audioopen-P61_cn(a3)
  1563.  
  1564.     lea     P61_timerint(pc),a1
  1565.     move.l  a1,P61_timerdata-P61_cn(a3)
  1566.     lea     P61_lev6server(pc),a1
  1567.     move.l  a1,P61_timerdata+8-P61_cn(a3)
  1568.  
  1569.     moveq   #0,d3
  1570.     lea     P61_cianame(pc),a1
  1571. P61_openciares
  1572.     moveq   #0,d0
  1573.     move.l  4.w,a6
  1574.     jsr     -$1f2(a6)
  1575.     move.l  d0,P61_ciares-P61_cn(a3)
  1576.     beq.b   P61_err
  1577.     move.l  d0,a6
  1578.     lea     P61_timerinterrupt(pc),a1
  1579.     moveq   #0,d0
  1580.     jsr     -6(a6)
  1581.     tst.l   d0
  1582.     beq.b   P61_gottimer
  1583.     addq.l  #4,d3
  1584.     lea     P61_timerinterrupt(pc),a1
  1585.     moveq   #1,d0
  1586.     jsr     -6(a6)
  1587.     tst.l   d0
  1588.     bne.b   P61_err
  1589.  
  1590. P61_gottimer
  1591.     lea     P61_craddr+8(pc),a6
  1592.     move.l  P61_ciaaddr(pc,d3),d0
  1593.     move.l  d0,(a6)
  1594.     sub     #$100,d0
  1595.     move.l  d0,-(a6)
  1596.     moveq   #2,d3
  1597.     btst    #9,d0
  1598.     bne.b   P61_timerB
  1599.     subq.b  #1,d3
  1600.     add     #$100,d0
  1601. P61_timerB
  1602.     add     #$900,d0
  1603.     move.l  d0,-(a6)
  1604.     move.l  d0,a0
  1605.     and.b   #%10000000,(a0)
  1606.     move.b  d3,P61_timeropen-P61_cn(a3)
  1607.     moveq   #0,d0
  1608.     ifne    CIA
  1609.     move.l  P61_craddr+4(pc),a1
  1610.     move.b  P61_tlo(pc),(a1)
  1611.     move.b  P61_thi(pc),$100(a1)
  1612.     endc
  1613.     or.b    #$19,(a0)
  1614.     st      P61_timeron-P61_cn(a3)
  1615. P61_pois
  1616.     move.l  (sp)+,a6
  1617.     rts
  1618.  
  1619. P61_err moveq   #-1,d0
  1620.     bra.b   P61_pois
  1621.     rts
  1622.  
  1623. P61_ciaaddr
  1624.     dc.l    $bfd500,$bfd700
  1625.     endc
  1626.  
  1627. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1628. ;­      Call P61_End to stop the music          ­
  1629. ;­   A6 --> Customchip baseaddress ($DFF000)    ­
  1630. ;­              Uses D0/D1/A0/A1/A3             ­
  1631. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1632.  
  1633. P61_End moveq   #0,d0
  1634.     move    d0,$a8(a6)
  1635.     move    d0,$b8(a6)
  1636.     move    d0,$c8(a6)
  1637.     move    d0,$d8(a6)
  1638.     move    #$f,$96(a6)
  1639.  
  1640.     and.b   #~2,$bfe001
  1641.     move.b  P61_ofilter(pc),d0
  1642.     or.b    d0,$bfe001
  1643.  
  1644.     ifeq    system
  1645.     move    #$2000,$9a(a6)
  1646.     move.l  P61_vektori(pc),a0
  1647.     move.l  P61_oldlev6(pc),(a0)
  1648.     lea     $bfd000,a0
  1649.     lea     P61_timers(pc),a1
  1650.     move.b  (a1)+,$400(a0)
  1651.     move.b  (a1)+,$500(a0)
  1652.     move.b  (a1)+,$600(a0)
  1653.     move.b  (a1)+,$700(a0)
  1654.     move.b  #$10,$e00(a0)
  1655.     move.b  #$10,$f00(a0)
  1656.  
  1657.     else
  1658.  
  1659.     clr     P61_timeron-P61_cn(a3)
  1660.     move.l  a6,-(sp)
  1661.     lea     P61_cn(pc),a3
  1662.     moveq   #0,d0
  1663.     move.b  P61_timeropen(pc),d0
  1664.     beq.b   P61_rem1
  1665.     move.l  P61_ciares(pc),a6
  1666.     lea     P61_timerinterrupt(pc),a1
  1667.     subq.b  #1,d0
  1668.     jsr     -12(a6)
  1669. P61_rem1
  1670.     move.l  4.w,a6
  1671.     tst.b   P61_audioopen-P61_cn(a3)
  1672.     beq.b   P61_rem2
  1673.     lea     P61_allocreq(pc),a1
  1674.     jsr     -$1c2(a6)
  1675.     clr.b   P61_audioopen-P61_cn(a3)
  1676. P61_rem2
  1677.     moveq   #0,d0
  1678.     move.b  P61_sigbit(pc),d0
  1679.     bmi.b   P61_rem3
  1680.     jsr     -$150(a6)
  1681.     st      P61_sigbit-P61_cn(a3)
  1682. P61_rem3
  1683.     move.l  (sp)+,a6
  1684.     endc
  1685.     rts
  1686.  
  1687.     ifne    fade
  1688. P61_mfade
  1689.     move    P61_Master(pc),d0
  1690.     move    P61_temp0+P61_Shadow(pc),d1
  1691.     mulu    d0,d1
  1692.     lsr     #6,d1
  1693.     move    d1,$a8(a6)
  1694.  
  1695.     ifgt    channels-1
  1696.     move    P61_temp1+P61_Shadow(pc),d1
  1697.     mulu    d0,d1
  1698.     lsr     #6,d1
  1699.     move    d1,$b8(a6)
  1700.     endc
  1701.  
  1702.     ifgt    channels-2
  1703.     move    P61_temp2+P61_Shadow(pc),d1
  1704.     mulu    d0,d1
  1705.     lsr     #6,d1
  1706.     move    d1,$c8(a6)
  1707.     endc
  1708.  
  1709.     ifgt    channels-3
  1710.     move    P61_temp3+P61_Shadow(pc),d1
  1711.     mulu    d0,d1
  1712.     lsr     #6,d1
  1713.     move    d1,$d8(a6)
  1714.     endc
  1715.     rts
  1716.     endc
  1717.     
  1718.  
  1719. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1720. ;­ Call P61_SetPosition to jump to a specific   ­
  1721. ;­            position in the song.             ­
  1722. ;­ D0.l --> Position                            ­
  1723. ;­ Starts from the beginning if out of limits.  ­
  1724. ;­              Uses A0/A1/A3/D0-D3             ­
  1725. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1726.  
  1727.     ifne    jump
  1728. P61_SetPosition
  1729.     lea     P61_cn(pc),a3
  1730.     ifne    P61_pl
  1731.     clr     P61_plflag-P61_cn(a3)
  1732.     endc
  1733.     moveq   #0,d1
  1734.     move.b  d0,d1
  1735.     move.l  d1,d0
  1736.     cmp     P61_slen-P61_cn(a3),d0
  1737.     blo.b   .e
  1738.     moveq   #0,d0
  1739. .e      move    d0,P61_Pos-P61_cn(a3)
  1740.     add.l   P61_possibase(pc),d0
  1741.     move.l  d0,P61_spos-P61_cn(a3)
  1742.  
  1743.     moveq   #64,d0
  1744.     move    d0,P61_rowpos-P61_cn(a3)
  1745.     clr     P61_CRow-P61_cn(a3)
  1746.     move.l  P61_spos(pc),a1
  1747.     move.l  P61_patternbase(pc),a0
  1748.     addq    #1,P61_Pos-P61_cn(a3)
  1749.     move.b  (a1)+,d0
  1750.     move.l  a1,P61_spos-P61_cn(a3)
  1751.     move.l  P61_positionbase(pc),a1
  1752.     move    d0,P61_Patt-P61_cn(a3)
  1753.     lsl     #3,d0
  1754.     add.l   d0,a1
  1755.     movem   (a1),d0-d3
  1756.     lea     (a0,d0.l),a1
  1757.     move    d1,d0
  1758.     move.l  a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  1759.     lea     (a0,d0.l),a1
  1760.     move.l  a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  1761.     move    d2,d0
  1762.     lea     (a0,d0.l),a1
  1763.     move.l  a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  1764.     move    d3,d0
  1765.     add.l   d0,a0
  1766.     move.l  a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  1767.     rts
  1768.     endc
  1769.  
  1770. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1771. ;­ Call P61_Music every frame to play the music ­
  1772. ;­        _NOT_ if CIA-version is used!         ­
  1773. ;­ A6 --> Customchip baseaddress ($DFF000)      ­
  1774. ;­              Uses A0-A5/D0-D7                ­
  1775. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  1776.  
  1777. P61_Music
  1778.     lea     P61_cn(pc),a3
  1779.  
  1780.     tst     P61_Play-P61_cn(a3)
  1781.     bne.b   P61_ohitaaa
  1782.     ifne    CIA
  1783.     ifne    system
  1784.     move.l  P61_craddr+4(pc),a0
  1785.     move.b  P61_tlo2(pc),(a0)
  1786.     move.b  P61_thi2(pc),$100(a0)
  1787.     endc
  1788.     endc
  1789.     rts
  1790.  
  1791. P61_ohitaaa
  1792.     ifne    fade
  1793.     pea     P61_mfade(pc)
  1794.     endc
  1795.  
  1796.     moveq   #Channel_Block_SIZE,d6
  1797.     moveq   #16,d7
  1798.  
  1799.     move    (a3),d4
  1800.     addq    #1,d4
  1801.     cmp     P61_speed(pc),d4
  1802.     beq     P61_playtime
  1803.  
  1804.     move    d4,(a3)
  1805.  
  1806. P61_delay
  1807.     ifne    CIA
  1808.     ifne    system
  1809.     move.l  P61_craddr+4(pc),a0
  1810.     move.b  P61_tlo2(pc),(a0)
  1811.     move.b  P61_thi2(pc),$100(a0)
  1812.     endc
  1813.     endc
  1814.  
  1815.     lea     P61_temp0(pc),a5
  1816.     lea     $a0(a6),a4
  1817.  
  1818.     moveq   #channels-1,d5
  1819. P61_lopas
  1820.     tst     P61_OnOff(a5)
  1821.     beq     P61_contfxdone
  1822.     moveq   #$f,d0
  1823.     and     (a5),d0
  1824.     ifeq    opt020
  1825.     add     d0,d0
  1826.     move    P61_jtab2(pc,d0),d0
  1827.     else
  1828.     move    P61_jtab2(pc,d0*2),d0
  1829.     endc
  1830.     jmp     P61_jtab2(pc,d0)
  1831.  
  1832. P61_jtab2
  1833.     dc      P61_contfxdone-P61_jtab2
  1834.  
  1835.     ifne    P61_pu
  1836.     dc      P61_portup-P61_jtab2
  1837.     else
  1838.     dc      P61_contfxdone-P61_jtab2
  1839.     endc
  1840.  
  1841.     ifne    P61_pd
  1842.     dc      P61_portdwn-P61_jtab2
  1843.     else
  1844.     dc      P61_contfxdone-P61_jtab2
  1845.     endc
  1846.  
  1847.     ifne    P61_tp
  1848.     dc      P61_toneport-P61_jtab2
  1849.     else
  1850.     dc      P61_contfxdone-P61_jtab2
  1851.     endc
  1852.  
  1853.     ifne    P61_vib
  1854.     dc      P61_vib2-P61_jtab2
  1855.     else
  1856.     dc      P61_contfxdone-P61_jtab2
  1857.     endc
  1858.  
  1859.     ifne    P61_tpvs
  1860.     dc      P61_tpochvslide-P61_jtab2
  1861.     else
  1862.     dc      P61_contfxdone-P61_jtab2
  1863.     endc
  1864.  
  1865.     ifne    P61_vbvs
  1866.     dc      P61_vibochvslide-P61_jtab2
  1867.     else
  1868.     dc      P61_contfxdone-P61_jtab2
  1869.     endc
  1870.  
  1871.     ifne    P61_tre
  1872.     dc      P61_tremo-P61_jtab2
  1873.     else
  1874.     dc      P61_contfxdone-P61_jtab2
  1875.     endc
  1876.  
  1877.     ifne    P61_arp
  1878.     dc      P61_arpeggio-P61_jtab2
  1879.     else
  1880.     dc      P61_contfxdone-P61_jtab2
  1881.     endc
  1882.  
  1883.     dc      P61_contfxdone-P61_jtab2
  1884.  
  1885.     ifne    P61_vs
  1886.     dc      P61_volslide-P61_jtab2
  1887.     else
  1888.     dc      P61_contfxdone-P61_jtab2
  1889.     endc
  1890.  
  1891.     dc      P61_contfxdone-P61_jtab2
  1892.     dc      P61_contfxdone-P61_jtab2
  1893.     dc      P61_contfxdone-P61_jtab2
  1894.  
  1895.     ifne    P61_ec
  1896.     dc      P61_contecommands-P61_jtab2
  1897.     else
  1898.     dc      P61_contfxdone-P61_jtab2
  1899.     endc
  1900.     dc      P61_contfxdone-P61_jtab2
  1901.  
  1902.     ifne    P61_ec
  1903. P61_contecommands
  1904.     move.b  P61_Info(a5),d0
  1905.     and     #$f0,d0
  1906.     lsr     #3,d0
  1907.     move    P61_etab2(pc,d0),d0
  1908.     jmp     P61_etab2(pc,d0)
  1909.  
  1910. P61_etab2
  1911.     dc      P61_contfxdone-P61_etab2
  1912.  
  1913.     ifne    P61_fsu
  1914.     dc      P61_fineup2-P61_etab2
  1915.     else
  1916.     dc      P61_contfxdone-P61_etab2
  1917.     endc
  1918.  
  1919.     ifne    P61_fsd
  1920.     dc      P61_finedwn2-P61_etab2
  1921.     else
  1922.     dc      P61_contfxdone-P61_etab2
  1923.     endc
  1924.  
  1925.     dc      P61_contfxdone-P61_etab2
  1926.     dc      P61_contfxdone-P61_etab2
  1927.  
  1928.     dc      P61_contfxdone-P61_etab2
  1929.     dc      P61_contfxdone-P61_etab2
  1930.  
  1931.     dc      P61_contfxdone-P61_etab2
  1932.     dc      P61_contfxdone-P61_etab2
  1933.  
  1934.     ifne    P61_rt
  1935.     dc      P61_retrig-P61_etab2
  1936.     else
  1937.     dc      P61_contfxdone-P61_etab2
  1938.     endc
  1939.  
  1940.     ifne    P61_fvu
  1941.     dc      P61_finevup2-P61_etab2
  1942.     else
  1943.     dc      P61_contfxdone-P61_etab2
  1944.     endc
  1945.  
  1946.     ifne    P61_fvd
  1947.     dc      P61_finevdwn2-P61_etab2
  1948.     else
  1949.     dc      P61_contfxdone-P61_etab2
  1950.     endc
  1951.  
  1952.     ifne    P61_nc
  1953.     dc      P61_notecut-P61_etab2
  1954.     else
  1955.     dc      P61_contfxdone-P61_etab2
  1956.     endc
  1957.  
  1958.     ifne    P61_nd
  1959.     dc      P61_notedelay-P61_etab2
  1960.     else
  1961.     dc      P61_contfxdone-P61_etab2
  1962.     endc
  1963.  
  1964.     dc      P61_contfxdone-P61_etab2
  1965.     dc      P61_contfxdone-P61_etab2
  1966.     endc
  1967.  
  1968.     ifne    P61_fsu
  1969. P61_fineup2
  1970.     tst     (a3)
  1971.     bne     P61_contfxdone
  1972.     moveq   #$f,d0
  1973.     and.b   P61_Info(a5),d0
  1974.     sub     d0,P61_Period(a5)
  1975.     moveq   #113,d0
  1976.     cmp     P61_Period(a5),d0
  1977.     ble.b   .jup
  1978.     move    d0,P61_Period(a5)
  1979. .jup    move    P61_Period(a5),6(a4)
  1980.     bra     P61_contfxdone
  1981.     endc
  1982.  
  1983.     ifne    P61_fsd
  1984. P61_finedwn2
  1985.     tst     (a3)
  1986.     bne     P61_contfxdone
  1987.     moveq   #$f,d0
  1988.     and.b   P61_Info(a5),d0
  1989.     add     d0,P61_Period(a5)
  1990.     cmp     #856,P61_Period(a5)
  1991.     ble.b   .jup
  1992.     move    #856,P61_Period(a5)
  1993. .jup    move    P61_Period(a5),6(a4)
  1994.     bra     P61_contfxdone
  1995.     endc
  1996.  
  1997.     ifne    P61_fvu
  1998. P61_finevup2
  1999.     tst     (a3)
  2000.     bne     P61_contfxdone
  2001.     moveq   #$f,d0
  2002.     and.b   P61_Info(a5),d0
  2003.     add     d0,P61_Volume(a5)
  2004.     moveq   #64,d0
  2005.     cmp     P61_Volume(a5),d0
  2006.     bge.b   .jup
  2007.     move    d0,P61_Volume(a5)
  2008. .jup    move    P61_Volume(a5),8(a4)
  2009.     bra     P61_contfxdone
  2010.     endc
  2011.  
  2012.     ifne    P61_fvd
  2013. P61_finevdwn2
  2014.     tst     (a3)
  2015.     bne     P61_contfxdone
  2016.     moveq   #$f,d0
  2017.     and.b   P61_Info(a5),d0
  2018.     sub     d0,P61_Volume(a5)
  2019.     bpl.b   .jup
  2020.     clr     P61_Volume(a5)
  2021. .jup    move    P61_Volume(a5),8(a4)
  2022.     bra     P61_contfxdone
  2023.     endc
  2024.  
  2025.     ifne    P61_nc
  2026. P61_notecut
  2027.     moveq   #$f,d0
  2028.     and.b   P61_Info(a5),d0
  2029.     cmp     (a3),d0
  2030.     bne     P61_contfxdone
  2031.     ifeq    fade
  2032.     clr     8(a4)
  2033.     else
  2034.     clr     P61_Shadow(a5)        *************************
  2035.     endc                          * Congratulations! You  *
  2036.     clr     P61_Volume(a5)        * have found the hidden *
  2037.     Bra     P61_contfxdone        * message!!! =)         *
  2038.     endc                          *************************
  2039.  
  2040.     ifne    P61_nd
  2041. P61_notedelay
  2042.     moveq   #$f,d0
  2043.     and.b   P61_Info(a5),d0
  2044.     cmp     (a3),d0
  2045.     bne     P61_contfxdone
  2046.  
  2047.     moveq   #$7e,d0
  2048.     and.b   (a5),d0
  2049.     beq     P61_contfxdone
  2050.     move    P61_DMABit(a5),d0
  2051.     move    d0,$96(a6)
  2052.     or      d0,P61_dma-P61_cn(a3)
  2053.     move.l  P61_Sample(a5),a1               ;* Trigger *
  2054.     move.l  (a1)+,(a4)+                     ;Pointer
  2055.     move    (a1),(a4)+                      ;Length
  2056.     move    P61_Period(a5),(a4)
  2057.     subq.l  #6,a4
  2058.  
  2059.     ifeq    system
  2060.     lea     P61_dmason(pc),a1
  2061.     move.l  P61_vektori(pc),a0
  2062.     move.l  a1,(a0)
  2063.     move.b  #$f0,$bfd600
  2064.     move.b  #$01,$bfd700
  2065.     move.b  #$19,$bfdf00
  2066.     else
  2067.     move    #1,P61_server-P61_cn(a3)
  2068.     move.l  P61_craddr+4(pc),a1
  2069.     move.b  #$f0,(a1)
  2070.     move.b  #1,$100(a1)
  2071.     endc
  2072.     bra     P61_contfxdone
  2073.     endc
  2074.  
  2075.     ifne    P61_rt
  2076. P61_retrig
  2077.     subq    #1,P61_RetrigCount(a5)
  2078.     bne     P61_contfxdone
  2079.     move    P61_DMABit(a5),d0
  2080.     move    d0,$96(a6)
  2081.     or      d0,P61_dma-P61_cn(a3)
  2082.     move.l  P61_Sample(a5),a1               ;* Trigger *
  2083.     move.l  (a1)+,(a4)                      ;Pointer
  2084.     move    (a1),4(a4)                      ;Length
  2085.  
  2086.     ifeq    system
  2087.     lea     P61_dmason(pc),a1
  2088.     move.l  P61_vektori(pc),a0
  2089.     move.l  a1,(a0)
  2090.     move.b  #$f0,$bfd600
  2091.     move.b  #$01,$bfd700
  2092.     move.b  #$19,$bfdf00
  2093.     else
  2094.     move    #1,P61_server-P61_cn(a3)
  2095.     move.l  P61_craddr+4(pc),a1
  2096.     move.b  #$f0,(a1)
  2097.     move.b  #1,$100(a1)
  2098.     endc
  2099.  
  2100.     moveq   #$f,d0
  2101.     and.b   P61_Info(a5),d0
  2102.     move    d0,P61_RetrigCount(a5)
  2103.     bra     P61_contfxdone
  2104.     endc
  2105.  
  2106.     ifne    P61_arp
  2107. P61_arplist
  2108.  dc.b 0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1
  2109.  
  2110. P61_arpeggio
  2111.     move    (a3),d0
  2112.     move.b  P61_arplist(pc,d0),d0
  2113.     beq.b   .arp0
  2114.     bmi.b   .arp1
  2115.  
  2116.     move.b  P61_Info(a5),d0
  2117.     lsr     #4,d0
  2118.     bra.b   .arp3
  2119.  
  2120. .arp0   move    P61_Note(a5),d0
  2121.     move    P61_periods(pc,d0),6(a4)
  2122.     bra     P61_contfxdone
  2123.  
  2124. .arp1   moveq   #$f,d0
  2125.     and.b   P61_Info(a5),d0
  2126.  
  2127. .arp3   add     d0,d0
  2128.     add     P61_Note(a5),d0
  2129.     move    P61_periods(pc,d0),6(a4)
  2130.     bra     P61_contfxdone
  2131.     endc
  2132.  
  2133. P61_periods
  2134.     ifne    P61_ft
  2135.     Incbin  "/periods"
  2136.     else
  2137.     Incbin  "/periods.nft"
  2138.     endc
  2139.  
  2140.     ifne    P61_vs
  2141. P61_volslide
  2142.     move.b  P61_Info(a5),d0
  2143.     sub.b   d0,P61_Volume+1(a5)
  2144.     bpl.b   .test
  2145.     clr     P61_Volume(a5)
  2146.     ifeq    fade
  2147.     clr     8(a4)
  2148.     else
  2149.     clr     P61_Shadow(a5)
  2150.     endc
  2151.     bra     P61_contfxdone
  2152. .test   moveq   #64,d0
  2153.     cmp     P61_Volume(a5),d0
  2154.     bge.b   .ncs
  2155.     move    d0,P61_Volume(a5)
  2156.     ifeq    fade
  2157.     move    d0,8(a4)
  2158.     else
  2159.     move    d0,P61_Shadow(a5)
  2160.     endc
  2161.     bra.b   P61_contfxdone
  2162. .ncs
  2163.     ifeq    fade
  2164.     move    P61_Volume(a5),8(a4)
  2165.     else
  2166.     move    P61_Volume(a5),P61_Shadow(a5)
  2167.     endc
  2168.     bra.b   P61_contfxdone
  2169.     endc
  2170.  
  2171.     ifne    P61_tpvs
  2172. P61_tpochvslide
  2173.     move.b  P61_Info(a5),d0
  2174.     sub.b   d0,P61_Volume+1(a5)
  2175.     bpl.b   .test
  2176.     clr     P61_Volume(a5)
  2177.     ifeq    fade
  2178.     clr     8(a4)
  2179.     else
  2180.     clr     P61_Shadow(a5)
  2181.     endc
  2182.     bra.b   P61_toneport
  2183. .test   moveq   #64,d0
  2184.     cmp     P61_Volume(a5),d0
  2185.     bge.b   .ncs
  2186.     move    d0,P61_Volume(a5)
  2187. .ncs
  2188.     ifeq    fade
  2189.     move    P61_Volume(a5),8(a4)
  2190.     else
  2191.     move    P61_Volume(a5),P61_Shadow(a5)
  2192.     endc
  2193.     endc
  2194.  
  2195.     ifne    P61_tp
  2196. P61_toneport
  2197.     move    P61_ToPeriod(a5),d0
  2198.     beq.b   P61_contfxdone
  2199.     move    P61_TPSpeed(a5),d1
  2200.     cmp     P61_Period(a5),d0
  2201.     blt.b   .topoup
  2202.  
  2203.     add     d1,P61_Period(a5)
  2204.     cmp     P61_Period(a5),d0
  2205.     bgt.b   .setper
  2206.     move    d0,P61_Period(a5)
  2207.     clr     P61_ToPeriod(a5)
  2208.     move    d0,6(a4)
  2209.     bra.b   P61_contfxdone
  2210.  
  2211. .topoup
  2212.     sub     d1,P61_Period(a5)
  2213.     cmp     P61_Period(a5),d0
  2214.     blt.b   .setper
  2215.     move    d0,P61_Period(a5)
  2216.     clr     P61_ToPeriod(a5)
  2217. .setper
  2218.     move    P61_Period(a5),6(a4)
  2219.     else
  2220.     nop
  2221.     endc
  2222.  
  2223. P61_contfxdone
  2224.     ifne    P61_il
  2225.     bsr     P61_funk2
  2226.     endc
  2227.  
  2228.     add.l   d6,a5
  2229.     add.l   d7,a4
  2230.     dbf     d5,P61_lopas
  2231.  
  2232.     cmp     P61_speed2(pc),d4
  2233.     beq.b   P61_preplay
  2234.     rts
  2235.  
  2236.     ifne    P61_pu
  2237. P61_portup
  2238.     moveq   #0,D0
  2239.     move.b  P61_Info(a5),d0
  2240.     sub     d0,P61_Period(a5)
  2241.     moveq   #113,d0
  2242.     cmp     P61_Period(a5),d0
  2243.     ble.b   .skip
  2244.     move    d0,P61_Period(a5)
  2245.     move    d0,6(a4)
  2246.     bra.b   P61_contfxdone
  2247. .skip
  2248.     move    P61_Period(a5),6(a4)
  2249.     bra.b   P61_contfxdone
  2250.     endc
  2251.  
  2252.     ifne    P61_pd
  2253. P61_portdwn
  2254.     moveq   #0,d0
  2255.     move.b  P61_Info(a5),d0
  2256.     add     d0,P61_Period(a5)
  2257.     cmp     #856,P61_Period(a5)
  2258.     ble.b   .skip
  2259.     move    #856,d0
  2260.     move    d0,P61_Period(a5)
  2261.     move    d0,6(a4)
  2262.     bra.b   P61_contfxdone
  2263. .skip
  2264.     move    P61_Period(a5),6(a4)
  2265.     bra.b   P61_contfxdone
  2266.     endc
  2267.  
  2268.     ifne    P61_pde
  2269. P61_return
  2270.     rts
  2271.  
  2272. P61_preplay
  2273.     tst     P61_pdflag-P61_cn(a3)
  2274.     bne.b   P61_return
  2275.     else
  2276. P61_preplay
  2277.     endc
  2278.  
  2279.     lea     P61_temp0(pc),a5
  2280.     lea     P61_samples-16(pc),a0
  2281.  
  2282.     moveq   #channels-1,d5
  2283. P61_loaps
  2284.     ifne    P61_pl
  2285.     lea     P61_TData(a5),a1
  2286.     move    2(a5),(a1)+
  2287.     move.l  P61_ChaPos(a5),(a1)+
  2288.     move.l  P61_TempPos(a5),(a1)+
  2289.     move    P61_TempLen(a5),(a1)
  2290.     endc
  2291.  
  2292.     move.b  P61_Pack(a5),d0
  2293.     and.b   #$3f,d0
  2294.     beq.b   P61_takeone
  2295.  
  2296.     tst.b   P61_Pack(a5)
  2297.     bmi.b   .keepsame
  2298.  
  2299.     subq.b  #1,P61_Pack(a5)
  2300.     clr     P61_OnOff(a5)                   ; Empty row
  2301.     add.l   d6,a5
  2302.     dbf     d5,P61_loaps
  2303.     rts
  2304.  
  2305. .keepsame
  2306.     subq.b  #1,P61_Pack(a5)
  2307.     bra     P61_dko
  2308.  
  2309. P61_takeone
  2310.     tst.b   P61_TempLen+1(a5)
  2311.     beq.b   P61_takenorm
  2312.  
  2313.     subq.b  #1,P61_TempLen+1(a5)
  2314.     move.l  P61_TempPos(a5),a2
  2315.  
  2316. P61_jedi
  2317.     move.b  (a2)+,d0
  2318.     moveq   #%01100000,d1
  2319.     and.b   d0,d1
  2320.     cmp.b   #%01100000,d1
  2321.     bne.b   .all
  2322.  
  2323.     moveq   #%01110000,d1
  2324.     and.b   d0,d1
  2325.     cmp.b   #%01110000,d1
  2326.     bne.b   .cmd
  2327.  
  2328.     moveq   #%01111000,d1
  2329.     and.b   d0,d1
  2330.     cmp.b   #%01111000,d1
  2331.     bne.b   .note
  2332.  
  2333. .empty  clr     P61_OnOff(a5)                   ; Empty row
  2334.     clr     (a5)+
  2335.     clr.b   (a5)+
  2336.     tst.b   d0
  2337.     bpl.b   .ex
  2338.     move.b  (a2)+,(a5)                      ; Compression info
  2339.     bra.b   .ex
  2340.  
  2341. .all    move.b  d0,(a5)+
  2342.     ifeq    opt020
  2343.     move.b  (a2)+,(a5)+
  2344.     move.b  (a2)+,(a5)+
  2345.     else
  2346.     move    (a2)+,(a5)+
  2347.     endc
  2348.     tst.b   d0
  2349.     bpl.b   .ex
  2350.     move.b  (a2)+,(a5)                      ; Compression info
  2351.     bra.b   .ex
  2352.  
  2353. .cmd    moveq   #$f,d1
  2354.     and     d0,d1
  2355.     move    d1,(a5)+                        ; cmd
  2356.     move.b  (a2)+,(a5)+                     ; info
  2357.     tst.b   d0
  2358.     bpl.b   .ex
  2359.     move.b  (a2)+,(a5)                      ; Compression info
  2360.     bra.b   .ex
  2361.  
  2362. .note   moveq   #7,d1
  2363.     and     d0,d1
  2364.     lsl     #8,d1
  2365.     move.b  (a2)+,d1
  2366.     lsl     #4,d1
  2367.     move    d1,(a5)+
  2368.     clr.b   (a5)+   
  2369.     tst.b   d0
  2370.     bpl.b   .ex
  2371.     move.b  (a2)+,(a5)                      ; Compression info
  2372. .ex     subq.l  #3,a5
  2373.     move.l  a2,P61_TempPos(a5)
  2374.     bra     P61_dko
  2375.  
  2376.  
  2377. P61_takenorm
  2378.     move.l  P61_ChaPos(a5),a2
  2379.  
  2380.     move.b  (a2)+,d0
  2381.     moveq   #%01100000,d1
  2382.     and.b   d0,d1
  2383.     cmp.b   #%01100000,d1
  2384.     bne.b   .all
  2385.  
  2386.     moveq   #%01110000,d1
  2387.     and.b   d0,d1
  2388.     cmp.b   #%01110000,d1
  2389.     bne.b   .cmd
  2390.  
  2391.     moveq   #%01111000,d1
  2392.     and.b   d0,d1
  2393.     cmp.b   #%01111000,d1
  2394.     bne.b   .note
  2395.  
  2396. .empty  clr     P61_OnOff(a5)                   ; Empty row
  2397.     clr     (a5)+
  2398.     clr.b   (a5)+
  2399.     tst.b   d0
  2400.     bpl.b   .proccomp
  2401.     move.b  (a2)+,(a5)                      ; Compression info
  2402.     bra.b   .proccomp
  2403.  
  2404.  
  2405. .all    move.b  d0,(a5)+
  2406.     ifeq    opt020
  2407.     move.b  (a2)+,(a5)+
  2408.     move.b  (a2)+,(a5)+
  2409.     else
  2410.     move    (a2)+,(a5)+
  2411.     endc
  2412.     tst.b   d0
  2413.     bpl.b   .proccomp
  2414.     move.b  (a2)+,(a5)                      ; Compression info
  2415.     bra.b   .proccomp
  2416.  
  2417. .cmd    moveq   #$f,d1
  2418.     and     d0,d1
  2419.     move    d1,(a5)+                        ; cmd
  2420.     move.b  (a2)+,(a5)+                     ; info
  2421.     tst.b   d0
  2422.     bpl.b   .proccomp
  2423.     move.b  (a2)+,(a5)                      ; Compression info
  2424.     bra.b   .proccomp
  2425.  
  2426. .note   moveq   #7,d1
  2427.     and     d0,d1
  2428.     lsl     #8,d1
  2429.     move.b  (a2)+,d1
  2430.     lsl     #4,d1
  2431.     move    d1,(a5)+
  2432.     clr.b   (a5)+   
  2433.     tst.b   d0
  2434.     bpl.b   .proccomp
  2435.     move.b  (a2)+,(a5)                      ; Compression info
  2436.  
  2437. .proccomp
  2438.     subq.l  #3,a5
  2439.     move.l  a2,P61_ChaPos(a5)
  2440.  
  2441.     tst.b   d0
  2442.     bpl.b   P61_dko
  2443.  
  2444.     move.b  3(a5),d0
  2445.     move.b  d0,d1
  2446.     and     #%11000000,d1
  2447.     beq.b   P61_dko                         ; Empty datas
  2448.     cmp.b   #%10000000,d1
  2449.     beq.b   P61_dko                         ; Same datas
  2450.  
  2451.     clr.b   3(a5)
  2452.     and     #$3f,d0
  2453.     move.b  d0,P61_TempLen+1(a5)
  2454.  
  2455.     cmp.b   #%11000000,d1
  2456.     beq.b   .bit16                          ; 16-bit
  2457.  
  2458.     moveq   #0,d0                           ; 8-bit
  2459.     move.b  (a2)+,d0
  2460.     move.l  a2,P61_ChaPos(a5)
  2461.     sub.l   d0,a2
  2462.     bra     P61_jedi
  2463.  
  2464. .bit16  moveq   #0,d0
  2465.     ifeq    opt020
  2466.     move.b  (a2)+,d0
  2467.     lsl     #8,d0
  2468.     move.b  (a2)+,d0
  2469.     else
  2470.     move    (a2)+,d0
  2471.     endc
  2472.  
  2473.     move.l  a2,P61_ChaPos(a5)
  2474.     sub.l   d0,a2
  2475.     bra     P61_jedi
  2476.  
  2477.  
  2478. P61_dko st      P61_OnOff(a5)
  2479.     move    (a5),d0
  2480.     and     #$1f0,d0
  2481.     beq.b   .koto
  2482.     lea     (a0,d0),a1
  2483.     move.l  a1,P61_Sample(a5)
  2484.     ifne    P61_ft
  2485.     move.l  P61_SampleVolume(a1),P61_Volume(a5)
  2486.     else
  2487.     move    P61_SampleVolume(a1),P61_Volume(a5)
  2488.     endc
  2489.     ifne    P61_il
  2490.     move.l  P61_RepeatOffset(a1),P61_Wave(a5)
  2491.     endc
  2492.     ifne    P61_sof
  2493.     clr     P61_Offset(a5)
  2494.     endc
  2495.  
  2496. .koto   add.l   d6,a5
  2497.     dbf     d5,P61_loaps
  2498.     rts
  2499.  
  2500. P61_playtime
  2501.     clr     (a3)
  2502.  
  2503.     ifne    P61_pde
  2504.     tst     P61_pdelay-P61_cn(a3)
  2505.     beq.b   .djdj
  2506.     subq    #1,P61_pdelay-P61_cn(a3)
  2507.     bne     P61_delay
  2508.     tst     P61_speedis1-P61_cn(a3)
  2509.     bne     P61_delay
  2510.     clr     P61_pdflag-P61_cn(a3)
  2511.     bra     P61_delay
  2512. .djdj
  2513.     clr     P61_pdflag-P61_cn(a3)
  2514.     endc
  2515.  
  2516.     tst     P61_speedis1-P61_cn(a3)
  2517.     beq.b   .mo
  2518.     bsr     P61_preplay
  2519.  
  2520. .mo     lea     P61_temp0(pc),a5
  2521.     lea     $a0(a6),a4
  2522.  
  2523.     ifeq    system
  2524.     lea     P61_dmason(pc),a1
  2525.     move.l  P61_vektori(pc),a0
  2526.     move.l  a1,(a0)
  2527.     move.b  #$f0,$bfd600
  2528.     move.b  #$01,$bfd700
  2529.     move.b  #$19,$bfdf00
  2530.     else
  2531.     move    #1,P61_server-P61_cn(a3)
  2532.     move.l  P61_craddr+4(pc),a1
  2533.     move.b  #$f0,(a1)
  2534.     move.b  #1,$100(a1)
  2535.     endc
  2536.  
  2537.     lea     P61_periods(pc),a2
  2538.  
  2539.     moveq   #0,d4
  2540.     moveq   #channels-1,d5
  2541. P61_los tst     P61_OnOff(a5)
  2542.     beq.b   P61_nocha
  2543.  
  2544.     moveq   #$f,d0
  2545.     and     (a5),d0
  2546.     lea     P61_jtab(pc),a1
  2547.     add     d0,d0
  2548.     add.l   d0,a1
  2549.     add     (a1),a1
  2550.     jmp     (a1)
  2551.  
  2552. P61_fxdone
  2553.     moveq   #$7e,d0
  2554.     and.b   (a5),d0
  2555.     beq.b   P61_nocha
  2556.     ifne    P61_vib
  2557.     clr.b   P61_VibPos(a5)
  2558.     endc
  2559.     ifne    P61_tre
  2560.     clr.b   P61_TrePos(a5)
  2561.     endc
  2562.  
  2563.     ifne    P61_ft
  2564.     add     P61_Fine(a5),d0
  2565.     endc
  2566.     move    d0,P61_Note(a5)
  2567.     move    (a2,d0),P61_Period(a5)
  2568.  
  2569. P61_zample
  2570.     ifne    P61_sof
  2571.     tst     P61_Offset(a5)
  2572.     bne     P61_pek
  2573.     endc
  2574.  
  2575.     or      P61_DMABit(a5),d4
  2576.     move    d4,$96(a6)
  2577.     move.l  P61_Sample(a5),a1               ;* Trigger *
  2578.     move.l  (a1)+,(a4)                      ;Pointer
  2579.     move    (a1),4(a4)                      ;Length
  2580.  
  2581. P61_nocha
  2582.     ifeq    fade
  2583.     move.l  P61_Period(a5),6(a4)
  2584.     else
  2585.     move    P61_Period(a5),6(a4)
  2586.     move    P61_Volume(a5),P61_Shadow(a5)
  2587.     endc
  2588.  
  2589. P61_skip
  2590.     ifne    P61_il
  2591.     bsr     P61_funk2
  2592.     endc
  2593.  
  2594.     add.l   d6,a5
  2595.     add.l   d7,a4
  2596.     dbf     d5,P61_los
  2597.  
  2598.     move.b  d4,P61_dma+1-P61_cn(a3)
  2599.  
  2600.     ifne    P61_pl
  2601.     tst.b   P61_plflag+1-P61_cn(a3)
  2602.     beq.b   P61_ohittaa
  2603.  
  2604.     lea     P61_temp0(pc),a1
  2605.     lea     P61_looppos(pc),a0
  2606.     moveq   #channels-1,d0
  2607. .talt   move.b  1(a0),3(a1)
  2608.     addq.l  #2,a0
  2609.     move.l  (a0)+,P61_ChaPos(a1)
  2610.     move.l  (a0)+,P61_TempPos(a1)
  2611.     move    (a0)+,P61_TempLen(a1)
  2612.     add.l   d6,a1
  2613.     dbf     d0,.talt
  2614.  
  2615.     move    P61_plrowpos(pc),P61_rowpos-P61_cn(a3)
  2616.     clr.b   P61_plflag+1-P61_cn(a3)
  2617.     moveq   #63,d0
  2618.     sub     P61_rowpos-P61_cn(a3),d0
  2619.     move    d0,P61_CRow-P61_cn(a3)
  2620.     rts
  2621.     endc
  2622.  
  2623. P61_ohittaa
  2624.     subq    #1,P61_rowpos-P61_cn(a3)
  2625.     bmi.b   P61_nextpattern
  2626.     moveq   #63,d0
  2627.     sub     P61_rowpos-P61_cn(a3),d0
  2628.     move    d0,P61_CRow-P61_cn(a3)
  2629.     rts
  2630.  
  2631. P61_nextpattern
  2632.     ifne    P61_pl
  2633.     clr     P61_plflag-P61_cn(a3)
  2634.     endc
  2635.     move.l  P61_patternbase(pc),a4
  2636.     moveq   #63,d0
  2637.     move    d0,P61_rowpos-P61_cn(a3)
  2638.     clr     P61_CRow-P61_cn(a3)
  2639.     move.l  P61_spos(pc),a1
  2640.     addq    #1,P61_Pos-P61_cn(a3)
  2641.     move.b  (a1)+,d0
  2642.     bpl.b   P61_dk
  2643.     move.l  P61_possibase(pc),a1
  2644.     move.b  (a1)+,d0
  2645.     clr     P61_Pos-P61_cn(a3)
  2646. P61_dk  move.l  a1,P61_spos-P61_cn(a3)
  2647.     move    d0,P61_Patt-P61_cn(a3)
  2648.     lsl     #3,d0
  2649.     move.l  P61_positionbase(pc),a1
  2650.     add.l   d0,a1
  2651.  
  2652.     move    (a1)+,d0
  2653.     lea     (a4,d0.l),a2
  2654.     move.l  a2,P61_ChaPos+P61_temp0-P61_cn(a3)
  2655.     move    (a1)+,d0
  2656.     lea     (a4,d0.l),a2
  2657.     move.l  a2,P61_ChaPos+P61_temp1-P61_cn(a3)
  2658.     move    (a1)+,d0
  2659.     lea     (a4,d0.l),a2
  2660.     move.l  a2,P61_ChaPos+P61_temp2-P61_cn(a3)
  2661.     move    (a1),d0
  2662.     add.l   d0,a4
  2663.     move.l  a4,P61_ChaPos+P61_temp3-P61_cn(a3)
  2664.     rts
  2665.  
  2666.     ifne    P61_tp
  2667. P61_settoneport
  2668.     move.b  P61_Info(a5),d0
  2669.     beq.b   P61_toponochange
  2670.     move.b  d0,P61_TPSpeed+1(a5)
  2671. P61_toponochange
  2672.     moveq   #$7e,d0
  2673.     and.b   (a5),d0
  2674.     beq     P61_nocha
  2675.     add     P61_Fine(a5),d0
  2676.     move    d0,P61_Note(a5)
  2677.     move    (a2,d0),P61_ToPeriod(a5)
  2678.     bra     P61_nocha
  2679.     endc
  2680.  
  2681.     ifne    P61_sof
  2682. P61_sampleoffse
  2683.     moveq   #0,d1
  2684.     move    #$ff00,d1
  2685.     and     2(a5),d1
  2686.     bne.b   .deq
  2687.     move    P61_LOffset(a5),d1
  2688. .deq    move    d1,P61_LOffset(a5)
  2689.     add     d1,P61_Offset(a5)
  2690.  
  2691.     moveq   #$7e,d0
  2692.     and.b   (a5),d0
  2693.     beq     P61_nocha
  2694.  
  2695.     move    P61_Offset(a5),d2
  2696.     add     d1,P61_Offset(a5)               ; THIS IS A PT-FEATURE!
  2697.     move    d2,d1
  2698.  
  2699.     ifne    P61_vib
  2700.     clr.b   P61_VibPos(a5)
  2701.     endc
  2702.     ifne    P61_tre
  2703.     clr.b   P61_TrePos(a5)
  2704.     endc
  2705.  
  2706.     ifne    P61_ft
  2707.     add     P61_Fine(a5),d0
  2708.     endc
  2709.     move    d0,P61_Note(a5)
  2710.     move    (a2,d0),P61_Period(a5)
  2711.     bra.b   P61_hup
  2712.  
  2713. P61_pek moveq   #0,d1
  2714.     move    P61_Offset(a5),d1
  2715. P61_hup or      P61_DMABit(a5),d4
  2716.     move    d4,$96(a6)
  2717.     move.l  P61_Sample(a5),a1               ;* Trigger *
  2718.     move.l  (a1)+,d0
  2719.     add.l   d1,d0
  2720.     move.l  d0,(a4)                         ;Pointer
  2721.     lsr     #1,d1
  2722.     move    (a1),d0
  2723.     sub     d1,d0
  2724.     bpl.b   P61_offok
  2725.     move.l  -4(a1),(a4)                     ;Pointer is over the end
  2726.     moveq   #1,d0
  2727. P61_offok
  2728.     move    d0,4(a4)                        ;Length
  2729.     bra     P61_nocha
  2730.     endc
  2731.  
  2732.     ifne    P61_vl
  2733. P61_volum
  2734.     move.b  P61_Info(a5),P61_Volume+1(a5)
  2735.     bra     P61_fxdone
  2736.     endc
  2737.  
  2738.     ifne    P61_pj
  2739. P61_posjmp
  2740.     moveq   #0,d0
  2741.     move.b  P61_Info(a5),d0
  2742.     cmp     P61_slen-P61_cn(a3),d0
  2743.     blo.b   .e
  2744.     moveq   #0,d0
  2745. .e      move    d0,P61_Pos-P61_cn(a3)
  2746.     add.l   P61_possibase(pc),d0
  2747.     move.l  d0,P61_spos-P61_cn(a3)
  2748.     endc
  2749.  
  2750.     ifne    P61_pb
  2751. P61_pattbreak
  2752.     moveq   #64,d0
  2753.     move    d0,P61_rowpos-P61_cn(a3)
  2754.     clr     P61_CRow-P61_cn(a3)
  2755.     move.l  P61_spos(pc),a1
  2756.     move.l  P61_patternbase(pc),a0
  2757.     addq    #1,P61_Pos-P61_cn(a3)
  2758.     move.b  (a1)+,d0
  2759.     bpl.b   P61_dk2
  2760.     move.l  P61_possibase(pc),a1
  2761.     move.b  (a1)+,d0
  2762.     clr     P61_Pos-P61_cn(a3)
  2763. P61_dk2 move.l  a1,P61_spos-P61_cn(a3)
  2764.     move.l  P61_positionbase(pc),a1
  2765.     move    d0,P61_Patt-P61_cn(a3)
  2766.     lsl     #3,d0
  2767.     add.l   d0,a1
  2768.     movem   (a1),d0-d3
  2769.     lea     (a0,d0.l),a1
  2770.     move    d1,d0
  2771.     move.l  a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  2772.     lea     (a0,d0.l),a1
  2773.     move.l  a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  2774.     move    d2,d0
  2775.     lea     (a0,d0.l),a1
  2776.     move.l  a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  2777.     move    d3,d0
  2778.     add.l   d0,a0
  2779.     move.l  a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  2780.     bra     P61_fxdone
  2781.     endc
  2782.  
  2783.     ifne    P61_vib
  2784. P61_vibrato
  2785.     move.b  P61_Info(a5),d0
  2786.     beq     P61_fxdone
  2787.     move.b  d0,d1
  2788.     move.b  P61_VibCmd(a5),d2
  2789.     and.b   #$f,d0
  2790.     beq.b   P61_vibskip
  2791.     and.b   #$f0,d2
  2792.     or.b    d0,d2
  2793. P61_vibskip
  2794.     and.b   #$f0,d1
  2795.     beq.b   P61_vibskip2
  2796.     and.b   #$f,d2
  2797.     or.b    d1,d2
  2798. P61_vibskip2
  2799.     move.b  d2,P61_VibCmd(a5)
  2800.     bra     P61_fxdone
  2801.     endc
  2802.  
  2803.     ifne    P61_tre
  2804. P61_settremo
  2805.     move.b  P61_Info(a5),d0
  2806.     beq     P61_fxdone
  2807.     move.b  d0,d1
  2808.     move.b  P61_TreCmd(a5),d2
  2809.     moveq   #$f,d3
  2810.     and.b   d3,d0
  2811.     beq.b   P61_treskip
  2812.     and.b   #$f0,d2
  2813.     or.b    d0,d2
  2814. P61_treskip
  2815.     and.b   #$f0,d1
  2816.     beq.b   P61_treskip2
  2817.     and.b   d3,d2
  2818.     or.b    d1,d2
  2819. P61_treskip2
  2820.     move.b  d2,P61_TreCmd(a5)
  2821.     bra     P61_fxdone
  2822.     endc
  2823.  
  2824.     ifne    P61_ec
  2825. P61_ecommands
  2826.     move.b  P61_Info(a5),d0
  2827.     and.b   #$f0,d0
  2828.     lsr     #3,d0
  2829.     move    P61_etab(pc,d0),d0
  2830.     jmp     P61_etab(pc,d0)
  2831.  
  2832. P61_etab
  2833.     ifne    P61_fi
  2834.     dc      P61_filter-P61_etab
  2835.     else
  2836.     dc      P61_fxdone-P61_etab
  2837.     endc
  2838.  
  2839.     ifne    P61_fsu
  2840.     dc      P61_fineup-P61_etab
  2841.     else
  2842.     dc      P61_fxdone-P61_etab
  2843.     endc
  2844.  
  2845.     ifne    P61_fsd
  2846.     dc      P61_finedwn-P61_etab
  2847.     else
  2848.     dc      P61_fxdone-P61_etab
  2849.     endc
  2850.  
  2851.     dc      P61_fxdone-P61_etab
  2852.     dc      P61_fxdone-P61_etab
  2853.  
  2854.     ifne    P61_sft
  2855.     dc      P61_setfinetune-P61_etab
  2856.     else
  2857.     dc      P61_fxdone-P61_etab
  2858.     endc
  2859.  
  2860.     ifne    P61_pl
  2861.     dc      P61_patternloop-P61_etab
  2862.     else
  2863.     dc      P61_fxdone-P61_etab
  2864.     endc
  2865.  
  2866.     dc      P61_fxdone-P61_etab
  2867.  
  2868.     ifne    P61_timing
  2869.     dc      P61_sete8-P61_etab
  2870.     else
  2871.     dc      P61_fxdone-P61_etab
  2872.     endc
  2873.  
  2874.     ifne    P61_rt
  2875.     dc      P61_setretrig-P61_etab
  2876.     else
  2877.     dc      P61_fxdone-P61_etab
  2878.     endc
  2879.  
  2880.     ifne    P61_fvu
  2881.     dc      P61_finevup-P61_etab
  2882.     else
  2883.     dc      P61_fxdone-P61_etab
  2884.     endc
  2885.  
  2886.     ifne    P61_fvd
  2887.     dc      P61_finevdwn-P61_etab
  2888.     else
  2889.     dc      P61_fxdone-P61_etab
  2890.     endc
  2891.  
  2892.     dc      P61_fxdone-P61_etab
  2893.  
  2894.     ifne    P61_nd
  2895.     dc      P61_ndelay-P61_etab
  2896.     else
  2897.     dc      P61_fxdone-P61_etab
  2898.     endc
  2899.  
  2900.     ifne    P61_pde
  2901.     dc      P61_pattdelay-P61_etab
  2902.     else
  2903.     dc      P61_fxdone-P61_etab
  2904.     endc
  2905.  
  2906.     ifne    P61_il
  2907.     dc      P61_funk-P61_etab
  2908.     else
  2909.     dc      P61_fxdone-P61_etab
  2910.     endc
  2911.     endc
  2912.  
  2913.     ifne    P61_fi
  2914. P61_filter
  2915.     move.b  P61_Info(a5),d0
  2916.     and.b   #$fd,$bfe001
  2917.     or.b    d0,$bfe001
  2918.     bra     P61_fxdone
  2919.     endc
  2920.  
  2921.     ifne    P61_fsu
  2922. P61_fineup
  2923.     P61_getnote
  2924.  
  2925.     moveq   #$f,d0
  2926.     and.b   P61_Info(a5),d0
  2927.     sub     d0,P61_Period(a5)
  2928.     moveq   #113,d0
  2929.     cmp     P61_Period(a5),d0
  2930.     ble.b   .jup
  2931.     move    d0,P61_Period(a5)
  2932. .jup    moveq   #$7e,d0
  2933.     and.b   (a5),d0
  2934.     bne     P61_zample
  2935.     bra     P61_nocha
  2936.     endc
  2937.  
  2938.     ifne    P61_fsd
  2939. P61_finedwn
  2940.     P61_getnote
  2941.  
  2942.     moveq   #$f,d0
  2943.     and.b   P61_Info(a5),d0
  2944.     add     d0,P61_Period(a5)
  2945.     cmp     #856,P61_Period(a5)
  2946.     ble.b   .jup
  2947.     move    #856,P61_Period(a5)
  2948. .jup    moveq   #$7e,d0
  2949.     and.b   (a5),d0
  2950.     bne     P61_zample
  2951.     bra     P61_nocha
  2952.     endc
  2953.  
  2954.     ifne    P61_sft
  2955. P61_setfinetune
  2956.     moveq   #$f,d0
  2957.     and.b   P61_Info(a5),d0
  2958.     ifeq    opt020
  2959.     add     d0,d0
  2960.     move    P61_mulutab(pc,d0),P61_Fine(a5)
  2961.     else
  2962.     move    P61_mulutab(pc,d0*2),P61_Fine(a5)
  2963.     endc
  2964.     bra     P61_fxdone
  2965.  
  2966. P61_mulutab
  2967.     dc      0,74,148,222,296,370,444,518,592,666,740,814,888,962,1036,1110
  2968.     endc
  2969.  
  2970.     ifne    P61_pl
  2971. P61_patternloop
  2972.     moveq   #$f,d0
  2973.     and.b   P61_Info(a5),d0
  2974.     beq.b   P61_setloop
  2975.  
  2976.     tst.b   P61_plflag-P61_cn(a3)
  2977.     bne.b   P61_noset
  2978.  
  2979.     move    d0,P61_plcount-P61_cn(a3)
  2980.     st.b    P61_plflag-P61_cn(a3)
  2981. P61_noset
  2982.     tst     P61_plcount-P61_cn(a3)
  2983.     bne.b   P61_looppaa
  2984.     clr.b   P61_plflag-P61_cn(a3)
  2985.     bra     P61_fxdone
  2986.     
  2987. P61_looppaa
  2988.     st.b    P61_plflag+1-P61_cn(a3)
  2989.     subq    #1,P61_plcount-P61_cn(a3)
  2990.     bra     P61_fxdone
  2991.  
  2992. P61_setloop
  2993.     tst.b   P61_plflag-P61_cn(a3)
  2994.     bne     P61_fxdone
  2995.     move    P61_rowpos(pc),P61_plrowpos-P61_cn(a3)
  2996.     lea     P61_temp0+P61_TData(pc),a1
  2997.     lea     P61_looppos(pc),a0
  2998.     moveq   #channels-1,d0
  2999. .talt   move.l  (a1)+,(a0)+
  3000.     move.l  (a1)+,(a0)+
  3001.     move.l  (a1),(a0)+
  3002.     subq.l  #8,a1
  3003.     add.l   d6,a1
  3004.     dbf     d0,.talt
  3005.     bra     P61_fxdone
  3006.     endc
  3007.  
  3008.     ifne    P61_fvu
  3009. P61_finevup
  3010.     moveq   #$f,d0
  3011.     and.b   P61_Info(a5),d0
  3012.     add     d0,P61_Volume(a5)
  3013.     moveq   #64,d0
  3014.     cmp     P61_Volume(a5),d0
  3015.     bge     P61_fxdone
  3016.     move    d0,P61_Volume(a5)
  3017.     bra     P61_fxdone
  3018.     endc
  3019.  
  3020.     ifne    P61_fvd
  3021. P61_finevdwn
  3022.     moveq   #$f,d0
  3023.     and.b   P61_Info(a5),d0
  3024.     sub     d0,P61_Volume(a5)
  3025.     bpl     P61_fxdone
  3026.     clr     P61_Volume(a5)
  3027.     bra     P61_fxdone
  3028.     endc
  3029.  
  3030.     ifne    P61_timing
  3031. P61_sete8
  3032.     moveq   #$f,d0
  3033.     and.b   P61_Info(a5),d0
  3034.     move    d0,P61_E8-P61_cn(a3)
  3035.     bra     P61_fxdone
  3036.     endc
  3037.  
  3038.     ifne    P61_rt
  3039. P61_setretrig
  3040.     moveq   #$f,d0
  3041.     and.b   P61_Info(a5),d0
  3042.     move    d0,P61_RetrigCount(a5)
  3043.     bra     P61_fxdone
  3044.     endc
  3045.  
  3046.     ifne    P61_nd
  3047. P61_ndelay
  3048.     moveq   #$7e,d0
  3049.     and.b   (a5),d0
  3050.     beq     P61_skip
  3051.     ifne    P61_vib
  3052.     clr.b   P61_VibPos(a5)
  3053.     endc
  3054.     ifne    P61_tre
  3055.     clr.b   P61_TrePos(a5)
  3056.     endc
  3057.     ifne    P61_ft
  3058.     add     P61_Fine(a5),d0
  3059.     endc
  3060.     move    d0,P61_Note(a5)
  3061.     move    (a2,d0),P61_Period(a5)
  3062.     ifeq    fade
  3063.     move    P61_Volume(a5),8(a4)
  3064.     else
  3065.     move    P61_Volume(a5),P61_Shadow(a5)
  3066.     endc
  3067.     bra     P61_skip
  3068.     endc
  3069.  
  3070.     ifne    P61_pde
  3071. P61_pattdelay
  3072.     moveq   #$f,d0
  3073.     and.b   P61_Info(a5),d0
  3074.     move    d0,P61_pdelay-P61_cn(a3)
  3075.     st      P61_pdflag-P61_cn(a3)
  3076.     bra     P61_fxdone
  3077.     endc
  3078.  
  3079.     ifne    P61_sd
  3080. P61_cspeed
  3081.     moveq   #0,d0
  3082.     move.b  P61_Info(a5),d0
  3083.  
  3084.     ifne    CIA
  3085.     tst     P61_Tempo-P61_cn(a3)
  3086.     beq.b   P61_VBlank
  3087.     cmp.b   #32,d0
  3088.     bhs.b   P61_STempo
  3089.     endc
  3090.  
  3091. P61_VBlank
  3092.     cmp.b   #1,d0
  3093.     beq.b   P61_jkd
  3094.  
  3095.     move.b  d0,P61_speed+1-P61_cn(a3)
  3096.     subq.b  #1,d0
  3097.     move.b  d0,P61_speed2+1-P61_cn(a3)
  3098.     clr     P61_speedis1-P61_cn(a3)
  3099.     bra     P61_fxdone
  3100.  
  3101. P61_jkd move.b  d0,P61_speed+1-P61_cn(a3)
  3102.     move.b  d0,P61_speed2+1-P61_cn(a3)
  3103.     st      P61_speedis1-P61_cn(a3)
  3104.     bra     P61_fxdone
  3105.  
  3106.  
  3107.     ifne    CIA
  3108. P61_STempo
  3109.     move.l  P61_timer(pc),d1
  3110.     divu    d0,d1
  3111.     move    d1,P61_thi2-P61_cn(a3)
  3112.     sub     #$1f0*2,d1
  3113.     move    d1,P61_thi-P61_cn(a3)
  3114.  
  3115.     ifeq    system
  3116.     move    P61_thi2-P61_cn(a3),d1
  3117.     move.b  d1,$bfd400
  3118.     lsr     #8,d1
  3119.     move.b  d1,$bfd500
  3120.     endc
  3121.  
  3122.     bra     P61_fxdone
  3123.     endc
  3124.     endc
  3125.  
  3126.  
  3127.  
  3128.     ifne    P61_vbvs
  3129. P61_vibochvslide
  3130.     move.b  P61_Info(a5),d0
  3131.     sub.b   d0,P61_Volume+1(a5)
  3132.     bpl.b   P61_test62
  3133.     clr     P61_Volume(a5)
  3134.     ifeq    fade
  3135.     clr     8(a4)
  3136.     else
  3137.     clr     P61_Shadow(a5)
  3138.     endc
  3139.     bra.b   P61_vib2
  3140. P61_test62
  3141.     moveq   #64,d0
  3142.     cmp     P61_Volume(a5),d0
  3143.     bge.b   .ncs2
  3144.     move    d0,P61_Volume(a5)
  3145. .ncs2
  3146.     ifeq    fade
  3147.     move    P61_Volume(a5),8(a4)
  3148.     else
  3149.     move    P61_Volume(a5),P61_Shadow(a5)
  3150.     endc
  3151.     endc
  3152.  
  3153.     ifne    P61_vib
  3154. P61_vib2
  3155.     move    #$f00,d0
  3156.     move    P61_VibCmd(a5),d1
  3157.     and     d1,d0
  3158.     lsr     #3,d0
  3159.  
  3160.     lsr     #2,d1
  3161.     and     #$1f,d1
  3162.     add     d1,d0
  3163.  
  3164.     move    P61_Period(a5),d1
  3165.     moveq   #0,d2
  3166.     move.b  P61_vibtab(pc,d0),d2
  3167.  
  3168.     tst.b   P61_VibPos(a5)
  3169.     bmi.b   .vibneg
  3170.     add     d2,d1
  3171.     bra.b   P61_vib4
  3172.  
  3173. .vibneg sub     d2,d1
  3174.  
  3175. P61_vib4
  3176.     move    d1,6(a4)
  3177.     move.b  P61_VibCmd(a5),d0
  3178.     lsr.b   #2,d0
  3179.     and     #$3c,d0
  3180.     add.b   d0,P61_VibPos(a5)
  3181.     bra     P61_contfxdone
  3182.     endc
  3183.  
  3184.     ifne    P61_tre
  3185. P61_tremo
  3186.     move    #$f00,d0
  3187.     move    P61_TreCmd(a5),d1
  3188.     and     d1,d0
  3189.     lsr     #3,d0
  3190.     
  3191.     lsr     #2,d1
  3192.     and     #$1f,d1
  3193.     add     d1,d0
  3194.  
  3195.     move    P61_Volume(a5),d1
  3196.     moveq   #0,d2
  3197.     move.b  P61_vibtab(pc,d0),d2
  3198.  
  3199.     tst.b   P61_TrePos(a5)
  3200.     bmi.b   .treneg
  3201.     add     d2,d1
  3202.     cmp     #64,d1
  3203.     ble.b   P61_tre4
  3204.     moveq   #64,d1
  3205.     bra.b   P61_tre4
  3206.  
  3207. .treneg sub     d2,d1
  3208.     bpl.b   P61_tre4
  3209.     moveq   #0,d1
  3210. P61_tre4
  3211.     ifeq    fade
  3212.     move    d1,8(a4)
  3213.     else
  3214.     move    d1,P61_Shadow(a5)
  3215.     endc
  3216.  
  3217.     move.b  P61_TreCmd(a5),d0
  3218.     lsr.b   #2,d0
  3219.     and     #$3c,d0
  3220.     add.b   d0,P61_TrePos(a5)
  3221.     bra     P61_contfxdone
  3222.     endc
  3223.  
  3224.     ifne    P61_vib!P61_tre
  3225. P61_vibtab      Incbin  "/vibtab"
  3226.     endc
  3227.  
  3228.     ifne    P61_il
  3229. P61_funk
  3230.     moveq   #$f,d0
  3231.     and.b   P61_Info(a5),d0
  3232.     move.b  d0,P61_Funkspd(a5)
  3233.     bra     P61_fxdone
  3234.  
  3235. P61_funk2
  3236.     moveq   #0,d0
  3237.     move.b  P61_Funkspd(a5),d0
  3238.     beq.b   P61_funkend
  3239.     move.b  P61_FunkTable(pc,d0),d0
  3240.     add.b   d0,P61_Funkoff(a5)
  3241.     bpl.b   P61_funkend
  3242.     clr.b   P61_Funkoff(a5)
  3243.  
  3244.     move.l  P61_Sample(a5),a1
  3245.     move.l  P61_RepeatOffset(a1),d1
  3246.     move    P61_RepeatLength(a1),d0
  3247.     add.l   d0,d0
  3248.     add.l   d1,d0
  3249.     move.l  P61_Wave(a5),a0
  3250.     addq.l  #1,a0
  3251.     cmp.l   d0,a0
  3252.     blo.b   P61_funkok
  3253.     move.l  d1,a0
  3254. P61_funkok
  3255.     move.l  a0,P61_Wave(a5)
  3256.     not.b   (a0)
  3257. P61_funkend
  3258.     rts
  3259.  
  3260. P61_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  3261.     endc
  3262.  
  3263. P61_jtab
  3264.     dc      P61_fxdone-*
  3265.     dc      P61_fxdone-*
  3266.     dc      P61_fxdone-*
  3267.  
  3268.     ifne    P61_tp
  3269.     dc      P61_settoneport-*
  3270.     else
  3271.     dc      P61_fxdone-*
  3272.     endc
  3273.  
  3274.     ifne    P61_vib
  3275.     dc      P61_vibrato-*
  3276.     else
  3277.     dc      P61_fxdone-*
  3278.     endc
  3279.  
  3280.     ifne    P61_tpvs
  3281.     dc      P61_toponochange-*
  3282.     else
  3283.     dc      P61_fxdone-*
  3284.     endc
  3285.  
  3286.     dc      P61_fxdone-*
  3287.  
  3288.     ifne    P61_tre
  3289.     dc      P61_settremo-*
  3290.     else
  3291.     dc      P61_fxdone-*
  3292.     endc
  3293.  
  3294.     dc      P61_fxdone-*
  3295.  
  3296.     ifne    P61_sof
  3297.     dc      P61_sampleoffse-*
  3298.     else
  3299.     dc      P61_fxdone-*
  3300.     endc
  3301.     dc      P61_fxdone-*
  3302.  
  3303.     ifne    P61_pj
  3304.     dc      P61_posjmp-*
  3305.     else
  3306.     dc      P61_fxdone-*
  3307.     endc
  3308.  
  3309.     ifne    P61_vl
  3310.     dc      P61_volum-*
  3311.     else
  3312.     dc      P61_fxdone-*
  3313.     endc
  3314.  
  3315.     ifne    P61_pb
  3316.     dc      P61_pattbreak-*
  3317.     else
  3318.     dc      P61_fxdone-*
  3319.     endc
  3320.  
  3321.     ifne    P61_ec
  3322.     dc      P61_ecommands-*
  3323.     else
  3324.     dc      P61_fxdone-*
  3325.     endc
  3326.     
  3327.     ifne    P61_sd
  3328.     dc      P61_cspeed-*
  3329.     else
  3330.     dc      P61_fxdone-*
  3331.     endc
  3332.  
  3333.  
  3334. P61_dmason
  3335.     ifeq    system
  3336.     tst.b   $bfdd00
  3337.     move    #$2000,$dff09c
  3338.     move.b  #$19,$bfdf00
  3339.     move.l  a0,-(sp)
  3340.     move.l  P61_vektori(pc),a0
  3341.     move.l  P61_intaddr(pc),(a0)
  3342.     move.l  (sp)+,a0
  3343.     move    P61_dma(pc),$dff096
  3344.     nop
  3345.     rte
  3346.  
  3347.     else
  3348.  
  3349.     move    P61_dma(pc),$96(a6)
  3350.     lea     P61_server(pc),a3
  3351.     addq    #1,(a3)
  3352.     move.l  P61_craddr(pc),a0
  3353.     move.b  #$19,(a0)
  3354.     bra     P61_ohi
  3355.     endc
  3356.  
  3357.  
  3358. P61_setrepeat
  3359.     ifeq    system
  3360.     tst.b   $bfdd00
  3361.     movem.l a0/a1,-(sp)
  3362.     lea     $dff0a0,a1
  3363.     move    #$2000,-4(a1)
  3364.     else
  3365.     lea     $a0(a6),a1
  3366.     endc
  3367.  
  3368.     move.l  P61_Sample+P61_temp0(pc),a0
  3369.     addq.l  #6,a0
  3370.     move.l  (a0)+,(a1)+
  3371.     move    (a0),(a1)
  3372.  
  3373.     ifgt    channels-1
  3374.     move.l  P61_Sample+P61_temp1(pc),a0
  3375.     addq.l  #6,a0
  3376.     move.l  (a0)+,12(a1)
  3377.     move    (a0),16(a1)
  3378.     endc
  3379.     
  3380.     ifgt    channels-2
  3381.     move.l  P61_Sample+P61_temp2(pc),a0
  3382.     addq.l  #6,a0
  3383.     move.l  (a0)+,28(a1)
  3384.     move    (a0),32(a1)
  3385.     endc
  3386.  
  3387.     ifgt    channels-3
  3388.     move.l  P61_Sample+P61_temp3(pc),a0
  3389.     addq.l  #6,a0
  3390.     move.l  (a0)+,44(a1)
  3391.     move    (a0),48(a1)
  3392.     endc
  3393.  
  3394.     ifne    system
  3395.     ifne    CIA
  3396.     lea     P61_server(pc),a3
  3397.     clr     (a3)
  3398.     move.l  P61_craddr+4(pc),a0
  3399.     move.b  P61_tlo(pc),(a0)
  3400.     move.b  P61_thi(pc),$100(a0)
  3401.     endc
  3402.     bra     P61_ohi
  3403.     endc
  3404.  
  3405.     ifeq    system
  3406.     ifne    CIA
  3407.     move.l  P61_vektori(pc),a0
  3408.     move.l  P61_tintti(pc),(a0)
  3409.     endc
  3410.     movem.l (sp)+,a0/a1
  3411.     nop
  3412.     rte
  3413.     endc
  3414.  
  3415. P61_temp0       dcb.b   Channel_Block_SIZE-2
  3416.         dc      1
  3417.  
  3418. P61_temp1       dcb.b   Channel_Block_SIZE-2
  3419.         dc      2
  3420.  
  3421. P61_temp2       dcb.b   Channel_Block_SIZE-2
  3422.         dc      4
  3423.  
  3424. P61_temp3       dcb.b   Channel_Block_SIZE-2
  3425.         dc      8
  3426.  
  3427. P61_cn          dc      0
  3428. P61_dma         dc      $8200
  3429. P61_rowpos      dc      0
  3430. P61_slen        dc      0
  3431. P61_speed       dc      0
  3432. P61_speed2      dc      0
  3433. P61_speedis1    dc      0
  3434. P61_spos        dc.l    0
  3435.  
  3436.     ifeq    system
  3437. P61_vektori     dc.l    0
  3438. P61_oldlev6     dc.l    0
  3439.     endc
  3440.  
  3441. P61_ofilter     dc      0
  3442. P61_timers      dc.l    0
  3443.  
  3444.     ifne    CIA
  3445. P61_tintti      dc.l    0
  3446. P61_thi         dc.b    0
  3447. P61_tlo         dc.b    0
  3448. P61_thi2        dc.b    0
  3449. P61_tlo2        dc.b    0
  3450. P61_timer       dc.l    0
  3451.     endc
  3452.  
  3453.     ifne    P61_pl
  3454. P61_plcount     dc      0
  3455. P61_plflag      dc      0
  3456. P61_plreset     dc      0
  3457. P61_plrowpos    dc      0
  3458. P61_looppos     dcb.b   12*channels
  3459.     endc
  3460.  
  3461.     ifne    P61_pde
  3462. P61_pdelay      dc      0
  3463. P61_pdflag      dc      0
  3464.     endc
  3465.  
  3466. P61_samples     dcb.b   16*31
  3467. P61_emptysample dcb.b   16
  3468. P61_positionbase dc.l   0
  3469. P61_possibase   dc.l    0
  3470. P61_patternbase dc.l    0
  3471. P61_intaddr     dc.l    0
  3472.  
  3473.     ifne    system
  3474. P61_server      dc      0
  3475. P61_miscbase    dc.l    0
  3476. P61_audioopen   dc.b    0
  3477. P61_sigbit      dc.b    -1
  3478. P61_ciares      dc.l    0
  3479. P61_craddr      dc.l    0,0,0
  3480. P61_dat         dc      $f00
  3481. P61_timerinterrupt dc   0,0,0,0,127
  3482. P61_timerdata   dc.l    0,0,0
  3483. P61_timeron     dc      0
  3484. P61_allocport   dc.l    0,0
  3485.         dc.b    4,0
  3486.         dc.l    0
  3487.         dc.b    0,0
  3488.         dc.l    0
  3489. P61_reqlist     dc.l    0,0,0
  3490.         dc.b    5,0
  3491. P61_allocreq    dc.l    0,0
  3492.         dc      127
  3493.         dc.l    0
  3494. P61_portti      dc.l    0
  3495.         dc      68
  3496.         dc.l    0,0,0
  3497.         dc      0
  3498. P61_reqdata     dc.l    0
  3499.         dc.l    1,0,0,0,0,0,0
  3500.         dc      0
  3501. P61_audiodev    dc.b    'audio.device',0
  3502.  
  3503. P61_cianame     dc.b    'ciab.resource',0
  3504. P61_timeropen   dc.b    0
  3505. P61_timerint    dc.b    'P61_TimerInterrupt',0,0
  3506.     endc
  3507. P61_etu
  3508.  
  3509.  
  3510. ******** END OF BINARY FILE **************
  3511. ;;;
  3512.  
  3513.            Section   chipdata,DATA_C     ;must lie in chipmem
  3514.  
  3515. ;;; "Dummy Copperlist"
  3516. DummyCopper:
  3517.            Dc.w      $0180,$0000
  3518.            IFND      noexample
  3519.            Dc.w      $6c01,$fffe
  3520.            Dc.w      $0180,$0499
  3521.            Dc.w      $7c01,$fffe
  3522.            Dc.w      $0180,$0555
  3523.            ENDC
  3524.            Dc.w      $ffff,$fffe
  3525.  
  3526. SpriteDummy:       Dc.l      0,0,0,0
  3527. ;;;
  3528. ;;; "Nasty Tune (Including sample data and buffer)"
  3529. P61_data:          Incbin    "!intro:loader/P61.mountai"
  3530.                  ;GLÖM INTE ÄNDRA SAMPLEBUFFERN!!!
  3531.                  ; + USECODEN!!!!²
  3532.  
  3533.            Section chipbss,bss_c
  3534. samples:           Ds.b      4732
  3535.                        ;Uncomment if you have packed samples
  3536.                        ;and insert sample buffer length.
  3537. ;;;
  3538.